|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
增加一个查询过程——
- <div>Sub 获取物料数()
- On Error Resume Next
- Dim rng As Range, arr, brr, i%, j%
- Dim sType$, sStatus$
- With ActiveSheet
- sType = .[U2].Value '选择类型
- sStatus = .[U3].Value '库存状态
- End With
- With Sheets("系统库存")
- Set rng = .Range("B4:AY" & .[B4].End(xlDown).Row)
- arr = rng
- ReDim brr(Application.CountIf(rng.Columns(2), sType), 8)
- For i = 1 To UBound(arr)
- If rng.Cells(i, 2) = sType And IIf(sStatus = "非零库存", rng.Cells(i, 48) > 0, True) Then
- j = j + 1
- brr(j, 1) = j
- brr(j, 2) = sType
- brr(j, 3) = rng.Cells(i, 1)
- brr(j, 4) = rng.Cells(i, 3)
- brr(j, 5) = rng.Cells(i, 4)
- brr(j, 6) = rng.Cells(i, 5)
- brr(j, 7) = rng.Cells(i, 49)
- brr(j, 8) = rng.Cells(i, 48)
- End If
- Next i
- End With
- With ActiveSheet
- .[B4:Ol99].ClearContents
- .[B4].Resize(UBound(brr, 1), UBound(brr, 2)) = brr
- End With
- End Sub</div>
复制代码
|
评分
-
1
查看全部评分
-
|