|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test()
- Dim r%, i%, m%
- Dim arr, brr, zrr()
- With Worksheets("新的工作表")
- r = .UsedRange.Find(what:="*", LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByRows, searchdirection:=xlPrevious).Row
- c = .UsedRange.Find(what:="*", LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByColumns, searchdirection:=xlPrevious).Column
- arr = .Range("a1").Resize(r, c)
- End With
- m = 0
- For i = 1 To UBound(arr)
- If arr(i, 1) = "计划组织:" Then
- m = m + 1
- ReDim Preserve zrr(1 To m)
- zrr(m) = Array(i, i)
- Else
- If m > 0 Then
- zrr(m)(1) = i
- End If
- End If
- Next
- ReDim brr(1 To UBound(arr), 1 To 6)
- m = 0
- For k = 1 To UBound(zrr)
- For i = zrr(k)(0) To zrr(k)(1)
- If arr(i, 1) Like "#*" Then
- m = m + 1
- brr(m, 1) = arr(zrr(k)(0), 4)
- brr(m, 2) = arr(zrr(k)(0), 6)
- brr(m, 3) = arr(i, 2)
- brr(m, 4) = arr(i, 3)
- brr(m, 5) = arr(i, 8)
- brr(m, 6) = arr(i, 10)
- End If
- Next
- Next
- With Worksheets("sheet1")
- .UsedRange.Offset(1, 0).Clear
- .Range("a:e").NumberFormatLocal = "@"
- .Range("a2").Resize(m, UBound(brr, 2)) = brr
- With .UsedRange
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- End Sub
复制代码 |
|