提问人:JulioBarcellos 提问时间:10/24/2023 最后编辑:FunThomasJulioBarcellos 更新时间:10/24/2023 访问量:44
VBA 自动筛选器得到错误的结果
VBA autofilter gets wrong results
问:
我制作了一个宏,在列上输入 vlookup 公式,然后它只过滤 #N/D 结果。此工作簿由 4 个不同的用户在他们自己的计算机上使用。在 3 台计算机上,它可以工作,但在 4 台计算机上,它会过滤 #N/D,但不会“显示”结果。 我不知道发生了什么,你能帮忙吗?
代码:
Application.ScreenUpdating = False
Dim wb As Workbook, wb2 As Workbook
Dim lastRowWithData
Set wb = ActiveWorkbook
Set wb2 = Workbooks.Open("\\server\path\file.xlsx")
wb2.Activate
Application.CutCopyMode = False
wb2.Sheets("NFe").Select
Range("X1").Value = "Procv"
wb2.Sheets("NFe").Range("X2").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-21]&RC[-19],'\\server\path\[file2.xlsm]SheetName'!C2,1,0)"
lastRowWithData = GetLastRowWithData
wb2.Sheets("NFe").Range("X2").Select
Selection.AutoFill Destination:=Range("X2:X" & lastRowWithData)
wb2.Sheets("NFe").Range("X1").Select
Selection.AutoFilter Field:=24, Criteria1:="#N/D"
这是第 4 台计算机显示的内容(Selection.AutoFilter Field:=24, Criteria1:=“#N/D”的调试模式):
答: 暂无答案
上一个:Excel 中的 VBA 饼图
评论