98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Recording Macro
Recording Macro
Resolved · Low Priority · Version 2003
Akiko has attended:
Excel VBA Intro Intermediate course
Recording Macro
I am not sure exactly when I should use
Variable Scope Dim vs Public
Hi Akiko
If you declare a variable as Dim it sets it up to be seen only by the procedure or module that contains it. For example:
Sub Test()
Dim MyName as String
MyName = "Carlos"
End Sub
If I wanted to access the value of MyName from another procedure it wouldn't find it.
So if the variable you are declaring needs to be accessible by all procedures and modules in a project then it needs to be declared as Public. For example:
Public MyName as String
Hope this helps
Carlos
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Conditional formatting for cells that return text , not picked up by Go to commandIf you have tried to format all cells containing text even those that display text as a result of a formula you may have had difficulty. As Go to command with constant selected does not pick up formulas that result in text. |