FilterSelectedValues

PHOTO EMBED

Wed Sep 08 2021 06:05:58 GMT+0000 (Coordinated Universal Time)

Saved by @cnewnham #vba

Sub FilterSelectedValues()
' This last one is used for filtering multiple values in a table. You paste the values you want to filter right below your table, then run the macro.
    Dim arrayEn() As Variant
    Dim selCol As Integer
    Dim rCell As Range
    Dim i As Long

    ReDim arrayEn(1 To 1, 1 To Selection.Count)
    selCol = Selection.Column
    i = 1

    For Each rCell In Selection
       arrayEn(1, i) = CStr(rCell.Value2)
       i = i + 1
    Next rCell

    ActiveSheet.Range("A1").AutoFilter field:=selCol, Criteria1:=arrayEn, Operator:=xlFilterValues
End Sub
content_copyCOPY