excxel的即时筛选出错
代码如下:
Private Sub TextBox1_Change()
For i = 1 To 6
ActiveSheet.UsedRange.AutoFilter Field:=i, Criteria1:="*" & TextBox1 & "*", Operator:=xlFilterValues
Next i
End Sub
报错
https://wzs07.lanzoue.com/iSOd50sai5xa
建议重装一下Excel。 参考官方文档https://learn.microsoft.com/zh-cn/office/vba/api/excel.autofilter?f1url=%3FappId%3DDev11IDEF1%26l%3Dzh-CN%26k%3Dk(vbaxl10.chm537072);k(TargetFrameworkMoniker-Office.Version%3Dv16)%26rd%3Dtrue
之前我就是遇到这个问题,读一遍demo再调试基本就懂了 录制宏,然后对录制的宏编辑代码,一般会避免很多语法错误 Dim ws As Worksheet
Dim rng As Range
Dim foundCell As Range
Set ws = ActiveSheet '获取当前激活的工作表
For Each rng In ws.Range("A1:F1")
Set foundCell = rng.Find(searchString, LookIn:=xlValues, LookAt:=xlPart)
If Not foundCell Is Nothing Then
'找到匹配单元格的操作
End If
Next rng 同一文本在六列中即时筛选,这样的话岂不是根据出不来结果 ? 楼主,但凡你有点耐心看看我的回复早搞定了
页:
[1]