试试看,结果在sheet2- Sub test()
- Dim arr, brr, i&, j&, t
- arr = Sheet1.Range("A4:AE24")
- ReDim brr(1 To UBound(arr), 0 To UBound(arr, 2))
- For j = 1 To UBound(arr, 2)
- brr(1, j) = arr(1, j)
- Next
- For i = 2 To UBound(arr) Step 2
- brr(i, 0) = arr(i, 3)
- brr(i + 1, 0) = arr(i, 11)
- For j = 1 To UBound(arr, 2)
- If arr(i + 1, j) <> "" Then
- t = Split(arr(i + 1, j), Chr(10))
- brr(i, j) = t(0)
- brr(i + 1, j) = t(UBound(t) - 1)
- End If
- Next
- Next
- Sheet2.Cells.ClearContents
- Sheet2.Range("A1").Resize(UBound(brr), 1 + UBound(brr)) = brr
- End Sub
复制代码 |