I am a noob in VBA and can't find a way to get the element of an array at a given index... It might be easy for you, though.
I have an excel file with 2 columns, "Emails" and "Categories", and I want to filter out all emails for a given category.
I ended up so far with the following code:
Sub filterEmails()
Dim tbl As ListObject
Dim emails As Variant
Dim email As String
Dim categories As Variant
Dim category As String
Dim i As Integer
Set tbl = ActiveWorkbook.Worksheets("Feuil1").ListObjects("Tableau1")
emails = tbl.ListColumns("EMAILS").DataBodyRange.Value
categories = tbl.ListColumns("SERVICES").DataBodyRange.Value
i = 1
For Each email In emails
category = ???
If category = "some service" Then
MsgBox email
End If
i = i + 1
Next email
End Sub
I tried many ways to get the ith item from the categories array, like categories(i)
but didn't succeed. It might be because I wasn't able to initialize variables with the right type.