|
各位老师:红色部分怎么改为直接赋值到数组,供后面的代码使用,谢谢1!!
With ListBox4
For i = 0 To .ListCount - 1
Sheets("报表").Range("hw" & i + 1) = .List(i, 0)
Next
End With
frr = .Range("hw1:hw" & .Range("hw65536").End(xlUp).Row + 1).Value
.Range("hw1:hw" & .Range("hw65536").End(xlUp).Row + 1).Clear
Set dic = CreateObject("scripting.dictionary")
For i = 1 To UBound(frr, 1)
dic(frr(i, 1)) = vbNullString
Next
arr = Sheets("数据库").[a1].CurrentRegion '筛选所选产品数量,写入数组arr
m = 2
For i = 3 To UBound(arr, 1)
If dic.exists(arr(i, 3)) Then
m = m + 1
For j = 1 To UBound(arr, 2)
arr(m, j) = arr(i, j)
Next
End If
Next
Worksheets.Add().Name = "辅助表"
Sheets("辅助表").Cells.Delete
Sheets("辅助表").Range("a1").Resize(m, UBound(arr, 2)) = arr
arr = Sheets("辅助表").[a1].CurrentRegion
drr = Sheets("数量").[a1].CurrentRegion '
m = 2
For i = 3 To UBound(drr, 1)
If dic.exists(drr(i, 3)) Then
m = m + 1
For j = 1 To UBound(drr, 2)
drr(m, j) = drr(i, j)
Next
End If
Next
Sheets("辅助表").Cells.Delete
Sheets("辅助表").Range("a1").Resize(m, UBound(drr, 2)) = drr
drr = Sheets("辅助表").[a1].CurrentRegion
Application.DisplayAlerts = False
Sheets("辅助表").Delete
Application.DisplayAlerts = True
|
|