|

楼主 |
发表于 2024-8-9 16:44
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
GPT给修改和,但是只能筛选文字,不能筛选数字...
Private Sub TextBox1_Change()
Dim descr_ As String
descr_ = "*" & TextBox1.Text & "*"
' 确保table1表格存在,然后应用筛选
If Not ActiveSheet.ListObjects("table1") Is Nothing Then
ActiveSheet.ListObjects("table1").Range.AutoFilter Field:=2, Criteria1:=descr_, Operator:=xlAnd
End If
End Sub
Sub load_()
On Error Resume Next
' 检查表格是否已经存在,如果不存在则创建它
If ActiveSheet.ListObjects.Count = 0 Then
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$2:$B$19385"), , xlYes).Name = "table1"
End If
' 创建表格或验证后,将焦点设置到TextBox1
ActiveSheet.Shapes("TextBox1").Select
Selection.ShapeRange(1).OLEFormat.Object.Activate
End Sub |
|