|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub sx()
Dim arr, brr, crr(1 To 9999, 1 To 8), i, j As Integer
arr = Sheets("信息库").Range("a1").CurrentRegion
brr = Sheets("派工单").Range("a1").CurrentRegion
Application.ScreenUpdating = False
For i = 1 To UBound(arr)
For j = 1 To UBound(brr)
If arr(i, 1) = brr(j, 1) Then
m = m + 1
crr(m, 1) = arr(i, 1): crr(m, 2) = arr(i, 2): crr(m, 3) = arr(i, 3): crr(m, 4) = arr(i, 6): crr(m, 5) = arr(i, 8): crr(m, 6) = arr(i, 10): crr(m, 7) = arr(i, 11): crr(m, 8) = arr(i, 7) 'sheet2中生成sheet1对应列数据
End If
Next
Next
With Sheet2
.[c2:j9999].Clear '生成数据的区域
.[c2].Resize(m, 8) = crr
.[c1].CurrentRegion.Borders.LineStyle = xlContinuous
End With
Application.ScreenUpdating = True
End Sub
运行时出现下标越界怎么处理??
|
|