|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test()
- Dim r%, i%
- Dim arr, brr
- With Worksheets("类别")
- r = .Cells(.Rows.Count, 2).End(xlUp).Row
- arr = .Range("a4:f" & r)
- ReDim brr(1 To UBound(arr), 1 To 3)
- m = 0
- For i = 1 To UBound(arr)
- If Len(arr(i, 2)) <> 0 And arr(i, 5) = True Then
- m = m + 1
- brr(m, 1) = arr(i, 2)
- brr(m, 2) = arr(i, 3)
- brr(m, 3) = arr(i, 4)
- End If
- Next
- r = .Cells(.Rows.Count, 7).End(xlUp).Row
- arr = .Range("g4:i" & r)
- ReDim crr(1 To UBound(arr), 1 To 1)
- n = 0
- For i = 1 To UBound(arr)
- If arr(i, 2) = True Then
- n = n + 1
- crr(n, 1) = arr(i, 1)
- End If
- Next
- End With
- With Worksheets("委托书")
- .Range("h11:v30").ClearContents
- If m > 0 Then
- .Range("h11").Resize(m, 1) = Application.Index(brr, 0, 1)
- .Range("k11").Resize(m, 1) = Application.Index(brr, 0, 2)
- .Range("o11").Resize(m, 1) = Application.Index(brr, 0, 3)
- End If
- If n > 0 Then
- .Range("s11").Resize(n, 1) = crr
- End If
- End With
- End Sub
复制代码 |
|