|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 swl4561255 于 2024-4-13 18:05 编辑
- Sub test()
- Range("A4:F100").ClearContents
- ar = Sheets("数据源").Range("A1").End(4).Row
- arr = Sheets("数据源").Range("A2:R" & ar)
- Dim brr(1 To 100, 1 To 6)
- myr = Array(12, 9, 16, 18, 4)
- For i = 1 To ar - 1
- If Int(arr(i, 12)) = [B3] Then
- m = m + 1
- brr(m, 1) = m
- For j = 2 To 6
- brr(m, j) = arr(i, myr(j - 2))
- Next
- End If
- Next
- If m = 0 Then
- MsgBox "未找到该日期对应的数据!"
- Exit Sub
- End If
- [A4].Resize(1, 6) = Array("No", "收货日期", "产品型号", "拉别", "工程师", "数量")
- [A5].Resize(m, 6) = brr
- End Sub
复制代码
代码优化了一下。 |
|