Excel VBA - using arrays
Posted on 2011-02-16
What I need to do is to loop through a range and if a cell matches any one of 8 strings to call another procedure. I had it working fine with a Select Case type approach but I was wondering if I could put the 8 funds into an array and then compare the array variable to the cell - something like the below (which doesn't work!). One ofmy motivaitons for asking this question is that I don't use arrays at all in my code at the moment so I'm looking to learn as much about them as possible.
Dim fund As Variant
fund = Array("GCEP", "GHYFND", "GREP", "GVEP", "WEMP", "WSSP", "GGEP", "GTRFND")
For x = 1 To Lastrow
code = Sheets("Dimension").Cells(x, 1)
If code Like fund Then