Filtering With Multiple Inputs from InputBox

1.8k views Asked by At

I'm trying to filter rows (keeping only values inputted) with multiple inputs to InputBox. With the values inputted, I want to create an array with which to AutoFilter my data.

What I have so far is below.

I'm stuck at splitting the inputs into an array?

Dim ticker As Variant
ticker = InputBox("Enter Stock Tickers Separated by Commas")

Dim MyArray As String
MyArray = Split(ticker, ",")


Range(Range("A2"), Range("A2").SpecialCells(xlLastCell)).Select
Selection.AutoFilter field:=6, Criteria:=MyArray
1

There are 1 answers

0
bigdayang On

Final code:

Dim ticker As Variant
ticker = InputBox("Enter Stock Tickers Separated by Commas")

Dim MyArray As Variant
MyArray = Split(ticker, ",")


Range(Range("A2"), Range("A2").SpecialCells(xlLastCell)).Select
Selection.AutoFilter field:=6, Criteria1:=Array(MyArray), Operator:=xlFilterValues