is there any difference when naming variables?
Posted by Pasi Vartiainen on July 13, 2000 1:10 AM
I have long macrocode, in begining of code there is macro which goes through all sheets in simple for next loop. In loop variable is increased by one. I start running in problems when I make jump out from loop:
---
Dim a As Integer
a = 1
For Each sh In ThisWorkbook.Worksheets
Sheets(a).Activate
If ActiveSheet.Name = "tc" Then GoTo hyppy
If ActiveSheet.Range("B4").Value = "Project Information" Then GoTo line0
If ActiveSheet.Range("B4").Value = "Line Up Information" Then GoTo line1
If ActiveSheet.Range("B4").Value = "MarineDrive Line-Up Information" Then GoTo line2
....
...
..
.
hyppy:
a = a + 1
Next
---
In above there are quite a lot those GoTo lines, and it is no idea to copy them all to here. Problem is that when jump is made to some line, for example line0, and code in there is runned, in some point variable "a" has value of zero, so I am getting a non-ending loop. When "a" is renamed to some other, for example "sheetnumber" it keeps it's value after jump. Does someone have explanation for this?
Thank's for excelent site.
Pasi Vartiainen