简单的VBAmacros,允许用户插入自定义号码

在我的macrosinputfilter的地方,我想开始一个对话框,用户可以在其中input自己的号码进行过滤。

 Sub Macro3() ActiveSheet.Range("$A$1:$CL$293662").AutoFilter Field:=19, Criteria1:= _ "=29301", Operator:=xlAnd End Sub 

试试这个。 代码中的注释。

 Public Sub test() Dim retval 'Get a value, very simple input box retval = InputBox("Please enter a number to filter by") 'Make sure the data is numeric If IsNumeric(retval) = False Then MsgBox "You didn't enter a number! Try again" Exit Sub End If 'Apply the filter ActiveSheet.Range("$A$1:$CL$293662").AutoFilter Field:=19, Criteria1:="=" & retval End Sub