1

company is an array containing unknown number of companies;

For i = 1 To 50
Worksheets("Data_Claims").Activate
Range("A1").AutoFilter _
Field:=1, _
Criteria1:=company(i)
If IsEmpty(company(i)) = True Then
Exit For
Next i
711
  • 11
  • 2

1 Answers1

0

If you want to filter the value within company, try this:

Worksheets("Data_Claims").Activate
Range("A1").AutoFilter _
Field:=1, _
Criteria1:=Array(company), _
Operator:=xlFilterValues

no need to use loop here

Aster Hu
  • 56
  • 3
  • No need `Array(company)` because `company` itself an array: `Worksheets("Data_Claims").Range("A1").AutoFilter Field:=1, Criteria1:=company, Operator:=xlFilterValues` – Алексей Р Jun 17 '21 at 09:52
  • @711 No problem! Would you mind selecting my answer if it helps you : ) ? – Aster Hu Jun 17 '21 at 17:48