I'm new to VBA and am trying to figure out categorize an excel sheet based on the contents of a column. My first problem is -I have an arraylist which I have populated with arrays, and-i'm having trouble accessing the elements of the arrays contained in the arraylist.(can use switch statement as word might be buried in text) The second problem is I have to intialise a new array rather than using the Object names- I have tried casting. Any help greatly appreciated.
'declare variable for the active cell for comparison
Dim ActiveTxt As String
Dim StringTxt As String
Dim Pop_Cell As Range
Dim msg As String
'intialize the Array list
Dim category_List As Object
Set category_List = CreateObject("System.Collections.ArrayList")
'Parent Array- has to match sequence of the intialised arrays
Dim Parent()
Parent = Array("Flights", "Accomodation", "Other_Subsistence")
'Array for Search terms
'**********************
'search terms are case sensitive
'**********************
Dim Flights()
Flights = Array("aerlin", "aerling", "ryanair", "ryan", "cityjet", "luft", "lufthansa", "aer", "transavia", "easyjet", "air", "swiss", "aero", "wow air"
Dim Accomodation()
Accomodation = Array("hotel")
Dim Other_Subsistence()
Other_Subsistence = Array("subsistance", "overnight")
'add Arrays to the arraylist
category_List.Add (Flights)
category_List.Add (Accomodation)
category_List.Add (Other_Subsistance)
'select first line of data
Range("A4").Select
'Set do loop to stop when an empty cell reached
Do Until IsEmpty(ActiveCell)
'to loop through the ArrayList (category_List)
For i = 0 To UBound(category_List(i))
'Loop through the Array
'For i = 0 To UBound(Flights)
'declaring variables for Search
ActiveTxt = ActiveCell.Text
'************************this is where the problem lies -used 1 as a test would use i and j and interate through them once it works
StringTxt = category_List.Item(1).get(1)
'Search by comparison- "if the cell contains this word"
If InStr(1, ActiveTxt, StringTxt) Then
'below makes a pop up box and populates it
'MsgBox ("found" & ActiveTxt)
'this populates the cell where the searched for value has been found with "flights" value
'*****this then needs to be Array
ActiveCell.Offset(0, 3).Value = StringTxt
'if found then exit the loop to stop searching though it
Exit For
Else
End If
Next i
Loop