|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 zxsea_7426 于 2023-3-10 15:47 编辑
就是第2条记录和第三条记录不要呗,循环起始点修改为4,同时提取的记录号减少2条
Sub 出库明细表提取数据_2()
Set d = CreateObject("scripting.dictionary")
With Sheets("出库明细")
r = .[a1048576].End(3).Row
If r > 1 Then
ar = Sheets("出库明细").[a2].CurrentRegion
Else
MsgBox "出库明细中无数据!"
Exit Sub
End If
End With
With Sheets("提取表")
r = .[a1048576].End(3).Row
If r > 2 Then .UsedRange.Offset(2).ClearContents
col_ = .Cells(2, Columns.Count).End(1).Column
ReDim br(1 To UBound(ar) - 2, 1 To col_) '定义数组大小
For j = 1 To col_
If .Cells(2, j) <> "" Then d(.Cells(2, j).Value) = j
br(1, j) = .Cells(2, j)
Next j
For j = 4 To UBound(ar, 2)
If d.exists(ar(1, j)) Then
l_ = d(ar(1, j))
For i = 4 To UBound(ar)
br(i - 2, l_) = ar(i, j)
br(i - 2, 12) = "加工车间"
Next i
End If
Next j
Sheets("提取表").[a2].Resize(UBound(br), UBound(br, 2)) = br
End With
End Sub
|
|