Looping question
I have the following code and I am experiencing a Run-time error 1004
Application-defined or object-defined error. The loop executes fine
the first time through but fails on the second pass. Any ideas are
appreciated. MyVar is valid the second time around too.
Public Sub Parse()
Dim myArr, myVar As Variant
Dim Unit As Variant
Set MyRange = Worksheets("Units").Range("A1:B11")
myArr = Split(ActiveCell.Value, ",")
For Each myVar In myArr ' Iterate through the array
'What do we do with each element?
x = Application.WorksheetFunction.VLookup(myVar, MyRange, 2,
False)
Next
End Sub
Thanks,
Charles
|