Ecxel VBA

Copper Contributor

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.

9 Replies

@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)

 

@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.

 

Στιγμιότυπο οθόνης (6).png

@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.

 

Στιγμιότυπο οθόνης (6).png

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

@NikolinoDE 

I can't insert the actual file, because it contains too many sensitive data.
However, it is much close to the example i gave you above.
The plan is to give a value (id as in the example), then the script should see the values of the other fields of that particular id and return a table filtered with those field as criteria. Exactly like the FILTER function in the given example.

The Excel version is 2016 and 2019 (can't remember the exact version) running on windows 10. The file used is stored in hard drive.

@Kalogeros 

Δείτε το συνημμένο αρχείο.

 

@NikolinoDE 

As i give id number (cell N3), i want to search all the other rows and find ids that have the same product (laptop-HP) and price (100) values with the given id, as shown below. I would also like to do this dynamically in the same table. All of that with VBA.

 

Thanks in advance.

 

Στιγμιότυπο οθόνης (11).png

@Kalogeros 

Hello,
Your project can actually best be done with Power Query.

For 2016 you would have to download it and paste it into Excel.
Here is an example in the file.
You can also use filters or do it with data slices.

With VBA it would be too cumbersome...in my humble opinion :).

 

Thank you for your patience and time.

 

@NikolinoDE 

Thanks for the reply, but unfortunately i haven't used Power Query before. So i can't understand what i'm supposed to do.