所以我遇到了能够指定数值的问题。例如,我希望能够做> 100用于使用输入盒的过滤器。我只能说像Action,AMERICAS等等。
Sub Criteria_Region_NewSheet()
Dim x As Long
Dim myValue As Variant
Dim mysheet As Variant
Application.ScreenUpdating = False
mysheet = ActiveSheet.Name
On Error Resume Next
y = Application.WorksheetFunction.Match("*", Range(Cells(1, 3), Cells(20, 3)), 0)
'Region is the criteria
x = Application.WorksheetFunction.Match("Sales", Range(Cells(1, y), Cells(100, y)), 0)
On Error GoTo 0
myValue = InputBox("Input Region")
On Error Resume Next
'Filter
Range(Cells(x, y), Cells(x, y)).AutoFilter Field:=x, Criteria1:=myValue
On Error GoTo 0
'Copies Information
Range(Cells(x, y), Cells(x, y)).Select
ActiveSheet.AutoFilter.Range.Copy
Worksheets.Add.Paste
'Formats columns
Columns("A:X").EntireColumn.AutoFit
Range("A1:F100").EntireRow.AutoFit
' Unfilter
Worksheets(mysheet).ShowAllData
Application.ScreenUpdating = True
End Sub