|
楼主 |
发表于 2023-4-9 11:43
|
显示全部楼层
求教大哥,这种也找不到数字格式的改用什么呢
Sub 库存查询()
Dim lh, sb
lh = Sheets("查询表").[c5].Text
sb = Sheets("查询表").[e5].Text
Sheets("查询表").Range("a8:u1000") = ""
Sheets("库存明细表").Range("b5:o5").Copy Sheets("查询表").[a8]
If lh = "" And sb = "" Then
MsgBox "查询条件不能为空!"
Exit Sub
End If
Dim area, mr, area1, rg, rr, n%
mr = Sheets("库存明细表").Cells(Rows.Count, 3).End(xlUp).Row
Set area = Sheets("库存明细表").Range("c6", "c" & mr)
For Each rg In area
If (lh = "" Or rg.Value = lh) And (sb = "" Or rg(1, 2) = sb) Then
rr = rg.Row
n = n + 1
Sheets("库存明细表").Range("c" & rr, "o" & rr).Copy
Sheets("查询表").Range("b" & 8 + n).PasteSpecial Paste:=xlPasteValues
Sheets("查询表").Range("a" & 8 + n) = n
End If
Next
MsgBox "查询完成!"
End Sub
|
|