|
用字典固定列号
- Sub ykcbf() '//2024.8.1
- Dim arr, brr, d
- Application.ScreenUpdating = False
- Set d = CreateObject("scripting.dictionary")
- arr = Sheets("输出表格").UsedRange
- For j = 1 To UBound(arr, 2)
- s = arr(1, j)
- d(s) = j
- Next
- With Sheets("数据表")
- r = .Cells(Rows.Count, 1).End(3).Row
- c = .UsedRange.Columns.Count
- arr = .[a1].Resize(r, c)
- End With
- ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2))
- For i = 3 To UBound(arr)
- If arr(i, 13) = "已发货" Then
- m = m + 1
- brr(m, 1) = m
- For j = 2 To UBound(arr, 2)
- s = arr(1, j)
- If d.exists(s) Then
- brr(m, d(s)) = arr(i, j)
- End If
- Next
-
- End If
- Next
- With Sheets("输出表格")
- .UsedRange.Offset(2).Interior.ColorIndex = 0
- .UsedRange.Offset(2) = ""
- Set Rng = .Range("a3").Resize(m, d.Count)
- Rng.Value = brr
- Rng.Borders.LineStyle = 1
- Rng.Interior.ColorIndex = 6
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|