使用InputBox中的多个输入进行过滤

时间:2015-06-18 16:51:23

标签: arrays vba excel-vba inputbox autofilter

我正在尝试使用InputBox的多个输入过滤行(仅保留输入的值)。输入值后,我想创建一个数组,使用该数组自动筛选我的数据。

到目前为止我的内容如下。

我坚持将输入分成数组?

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 个答案:

答案 0 :(得分:0)

最终代码:

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