Macro to filter on multiple fields

jimb2k

New Member
Joined
Apr 11, 2021
Messages
2
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello

I have a macro that I want to adapt to a change to add another filter.

I'm reading a text file with a format like this :



Rich (BB code):
"Name";"OperatingSystem";"OperatingSystemVersion"
"Test1";"Windows 10 Pro";"10.0 (18363)"
"Test2";"Windows 10 Enterprise";"10.0 (18363)"
"Test3";"Windows 10 Pro";"10.0 (18363)"
"Test4";"Windows 10 Enterprise";"10.0 (18363)"
"Test5";"Windows 10 Familial";"10.0 (18363)"

After that macro fill the cells with values filtred based on version os OS(10.0 (18363))

test.PNG

I want to add a filter on Windows 10 to count also the computer by OS (Pro, Ent), the structure of the table will change to this

test2.PNG

VBA Code:
    For i = 1 To k
    
        If Left(versions(j), 2) = "10" Then
        
            ActiveSheet.Range("$A$1:$D$500").AutoFilter Field:=3, Criteria1:=versions(j)
            findedversions(j) = Evaluate("=subtotal(3,A:A)") - 1
        Else
                        
                ActiveSheet.Range("$A$1:$D$500").AutoFilter Field:=3, Criteria1:=Left(versions(j), 3) & "*"
                ActiveSheet.Range("$A$1:$D$500").AutoFilter Field:=2, Criteria1:="=windows*", Operator:=xlAnd
                findedversions(j) = Evaluate("=subtotal(3,A:A)") - 1
            
            End If
        
        End If
       
   Next j

Thank you in advance for your help
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,214,920
Messages
6,122,276
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top