- Sub test()
- Dim r%, i%
- Dim arr, brr
- With Worksheets("sheet1")
- c = .Cells(1, 1).End(xlToRight).Column
- If c = 6 Then
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:f" & r)
- ReDim brr(1 To UBound(arr), 1 To 5)
- For i = 1 To UBound(arr)
- brr(i, 1) = arr(i, 1)
- brr(i, 2) = arr(i, 2)
- If arr(i, 3) = Empty Then
- brr(i, 3) = arr(i, 4)
- Else
- brr(i, 3) = arr(i, 3)
- End If
- brr(i, 4) = arr(i, 5)
- brr(i, 5) = arr(i, 6)
- Next
- .Cells(1, 4).Delete shift:=xlToLeft
- .Range("a2:e" & r) = brr
- End If
- End With
- End Sub
复制代码 |