-1

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
0m3r
  • 12,286
  • 15
  • 35
  • 71
bigdayang
  • 1
  • 1
  • Try `Dim MyArray As Variant` – Tim Williams Jun 18 '15 at 17:06
  • That seemed to help with the split function but now it's stopping at the AutoFilter. Any advice? – bigdayang Jun 18 '15 at 17:16
  • Whoops, just realized I left out the 1 after Criteria. 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 – bigdayang Jun 18 '15 at 17:21

1 Answers1

0

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
bigdayang
  • 1
  • 1