|
- Sub 拆分()
- Dim Arr, Brr, drow%, i%, j%, rng As Range, Crr()
- Arr = Worksheets("表1").Range("a1").CurrentRegion
- Set rng = Worksheets("表2").Range("a1:a2")
- With Worksheets("sheet1")
- For i = 2 To UBound(Arr)
- k = 3
- ReDim Crr(1 To 2, 1 To UBound(Arr, 2) + 2)
- Crr(1, 1) = Arr(1, 1): Crr(1, 2) = Arr(1, 2): Crr(2, 1) = Arr(i, 1): Crr(2, 2) = Arr(i, 2)
- For j = 3 To UBound(Arr, 2)
- If Arr(i, j) <> "" Then
- Crr(1, k) = Arr(1, j): Crr(2, k) = Arr(i, j): k = k + 1
- End If
- Next
- drow = .Range("a65536").End(3).Row
- rng.Copy .Cells(drow + 3, 1)
- .Range("b" & drow + 3).Resize(2, k) = Crr
- With .Range(.Cells(drow + 3, 1), .Cells(drow + 4, k))
- .Borders(xlEdgeTop).LineStyle = xlContinuous
- .Borders(xlEdgeLeft).LineStyle = xlContinuous
- .Borders(xlEdgeBottom).LineStyle = xlContinuous
- .Borders(xlEdgeRight).LineStyle = xlContinuous
- .Borders(xlInsideVertical).LineStyle = xlContinuous
- .Borders(xlInsideHorizontal).LineStyle = xlContinuous
- End With
- Erase Crr
- Next
- End With
- End Sub
复制代码 |
|