I have been getting a large number of answers from Stackoverflow and I really appreciate all of the information you experts have provided! This is my first time asking a question - so thank you.
I am running various VBA programs in the backend of a large Excel 2010 workbook and I am completely stumped on my current issue. In a Module, I have a public sub with a For Each loop that iterates through a variant which is loaded with a range of string values in a worksheet.
When I run this loop, I either get an immediate compile error "Variable not defined" and the for each variable is highlighted or the program runs but loops without end. I have literally commented everything out in the loop itself and I still get this issue. When the loop does run, I see the string value being correctly retrieved into the for each variable. If I comment out the loop then the sub runs without any issues.
Here is what I have to be clear:
Dim showWord as String
showWord = ""
For Each thisWord In allWords
'showWord = CStr(thisWord)
'MsgBox showWord
Next x
Now I have this exact same loop elsewhere in a different module and it always runs without issue. I did change both the for each variable and variant variable names but that was it.
Can somebody please help me figure out what is going on here?
Thank you.
thisWordandallWordsearlier in the code?