Forum Discussion

Kalogeros's avatar
Kalogeros
Copper Contributor
Aug 18, 2022

Ecxel VBA

Hi,

i would like to filter a table (5000+ rows, 20+ columns) with multiple criteria. More specifically, i would like to give a unique id ( 6digit NUMBER from the first column) and return ALL the other entries that have the exact same values in specific fields (columns) with this input.

  • NikolinoDE's avatar
    NikolinoDE
    Gold Contributor

    Kalogeros 

    VBA Code...

    Sub AutofilterInput()
    Dim Criterion1 As String, Range As Range
    Set Range = ActiveSheet.UsedRange ' Adjust range accordingly
    'Filter searches for "contains search text"
    Criterion1 = "=*" & InputBox("Text you're looking for?", "Autofilter search term", "Search text") & "*"
    If Criterion1 = "=**" Then Exit Sub
    Range.AutoFilter Field:=1, Criteria1:=Kriterium1 'If several columns have an auto filter, adjust the field number if necessary
    end sub

     

    ...or

    Filter by using advanced criteria

     

     

    Hope I could help you with these information / links.

     

    NikolinoDE

    I know I don't know anything (Socrates)

     

    • Kalogeros's avatar
      Kalogeros
      Copper Contributor

      NikolinoDE  Thanks for the reply, but it doesnt work for me.

      I want to replicate the FILTER function in Vba for Excel 2016-2019, as shown in the example below.

      If you have any questions please contact me.

       

      • NikolinoDE's avatar
        NikolinoDE
        Gold Contributor
        Please insert the file (without sensitive data) to have a clear view of the whole thing.
        At the same time, please describe your plans step by step.
        It would be advantageous to know the Excel version (e.g. 2016,16.0.5356.1001), operating system (win, mac, etc.) and storage medium (Sharepoint, OneDrive, hard drive, etc.).

        Thank you for your understanding and patience
    • Kalogeros's avatar
      Kalogeros
      Copper Contributor

      NikolinoDE  Thanks for the reply, but i'm trying to do something like the example below.

      I'm trying to replicate FILTER function with VBA in Excel 2016-2019.

      Ask me if there is anything you can't understand.

       

Resources