Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
With this new feature, it seems everything must be defined. It just told me
that "i" in my do loop was undefined. How should I dimension this? Thanks, Grace |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Grace
that's the purpose of option explicit (and by the way, its not a new feature - it must not have been turned on in your previous version) if i is a counter you can use dim i as long cheers JulieD "Grace" wrote in message ... With this new feature, it seems everything must be defined. It just told me that "i" in my do loop was undefined. How should I dimension this? Thanks, Grace |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Grace,
For a full discussion of Option Explicit go to Chip Pearson's page: http://www.cpearson.com/excel/DeclaringVariables.htm In this particular case, Option Explicit is telling you that i has not been dimmed (dimensioned). Solution: At the top of the Sub type: Dim i as long --- Regards, Norman "Grace" wrote in message ... With this new feature, it seems everything must be defined. It just told me that "i" in my do loop was undefined. How should I dimension this? Thanks, Grace |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, Norman, and Julie, and Bob.
Grace "Norman Jones" wrote in message ... Hi Grace, For a full discussion of Option Explicit go to Chip Pearson's page: http://www.cpearson.com/excel/DeclaringVariables.htm In this particular case, Option Explicit is telling you that i has not been dimmed (dimensioned). Solution: At the top of the Sub type: Dim i as long --- Regards, Norman "Grace" wrote in message ... With this new feature, it seems everything must be defined. It just told me that "i" in my do loop was undefined. How should I dimension this? Thanks, Grace |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The beauty of this feature is that it can capture typos, because each
variable must be explicitly declared. Consider this code For iRowCounter = 1 To 500 If Cells(iRowCounter,"A").Value = "" Then Cells(iRowCoanter,"B").Value = "X" End If Next i IF you don't have Option Explicit, it will run okay, but not work as the variable is mis-spelt in the action statement. If you have Option Explicit, it will not compile, so you will immediately force you to correct it. Could save hours of debugging. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Grace" wrote in message ... With this new feature, it seems everything must be defined. It just told me that "i" in my do loop was undefined. How should I dimension this? Thanks, Grace |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob Phillips wrote:
The beauty of this feature is that it can capture typos, because each variable must be explicitly declared. Consider this code For iRowCounter = 1 To 500 If Cells(iRowCounter,"A").Value = "" Then Cells(iRowCoanter,"B").Value = "X" End If Next i IF you don't have Option Explicit, it will run okay, but not work as the variable is mis-spelt in the action statement. If you have Option Explicit, it will not compile, so you will immediately force you to correct it. Could save hours of debugging. In fact, the above code won't run okay even without Option Explicit, first because the Next i line will cause the "Invalid Next control variable reference" error (a compile error), second because the iRowCoanter line will cause the "Application-defined or object-defined error" (a runtime error). An example to make the point could be: For iRowCounter = 1 To 500 If Cells(iRowCounter, "A").Value = "" Then Cells(iRowCoanter + 1, "B").Value = "X" End If Next iRowCounter Alan Beban |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Nit-picking point that adds nothing to the point being made.
Bob "Alan Beban" wrote in message ... Bob Phillips wrote: The beauty of this feature is that it can capture typos, because each variable must be explicitly declared. Consider this code For iRowCounter = 1 To 500 If Cells(iRowCounter,"A").Value = "" Then Cells(iRowCoanter,"B").Value = "X" End If Next i IF you don't have Option Explicit, it will run okay, but not work as the variable is mis-spelt in the action statement. If you have Option Explicit, it will not compile, so you will immediately force you to correct it. Could save hours of debugging. In fact, the above code won't run okay even without Option Explicit, first because the Next i line will cause the "Invalid Next control variable reference" error (a compile error), second because the iRowCoanter line will cause the "Application-defined or object-defined error" (a runtime error). An example to make the point could be: For iRowCounter = 1 To 500 If Cells(iRowCounter, "A").Value = "" Then Cells(iRowCoanter + 1, "B").Value = "X" End If Next iRowCounter Alan Beban |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Option Explicit | Excel Discussion (Misc queries) | |||
option explicit | Excel Discussion (Misc queries) | |||
Option Explicit Error | Excel Programming | |||
Implied Option Explicit in XP?? | Excel Programming | |||
Option Explicit and Arrays | Excel Programming |