这是我的答复,行不行你自行测试,不必再这里追问了,你可发新帖解决。- Option Explicit
- Sub test()
- Application.ScreenUpdating = False
- Dim lr&, ar, br, cr(), tr, x%, r&, i%, j%, y%, st$
- r = 2
- With Sheets("查看")
- lr = .Cells(Rows.Count, 2).End(xlUp).Row
- If lr > 2 Then
- With Sheets("资金")
- .[a:d] = ""
- .[a1] = "资金"
- End With
- If lr = 3 Then
- st = .[b3]
- tr = Split(Trim(st), ",")
- ReDim cr(10, 3)
- For x = 0 To UBound(tr)
- cr(0, x) = x
- cr(0, 3) = tr(x)
- Next
- cr(0, 0) = "序号"
- Sheets("资金").Cells(r, 1).Resize(11, 4) = cr
- Else
- For i = 3 To lr Step 3
- ReDim cr(10, 3)
- For x = 0 To UBound(cr)
- cr(x, 0) = x
- Next
- cr(0, 0) = "序号"
- j = 3
- br = .Cells(i, 2).Resize(3)
- For y = 1 To 3
- st = Trim(br(y, 1))
- If Len(st) Then
- tr = Split(st, ",")
- For x = 0 To UBound(tr)
- cr(x, j) = tr(x)
- Next
- End If
- j = j - 1
- Next
- Sheets("资金").Cells(r, 1).Resize(11, 4) = cr
- r = r + 12
- Next
- End If
- End If
- End With
- Err.Clear
- Application.ScreenUpdating = True
- End Sub
复制代码 |