How to Declare a Public Variable in VBA
While programming in VBA sometimes you need to declare a Public Variable which can store the value through out the program.
Use of Public Variable : Let’s say you have 4 different Functions in your VBA Code or Module and you have a variable which may or may not be modified in any of the Functions during the execution. But whenever you want to use that variable, you want to latest value. In such case Public Variable is useful.
Public Variable must be defined under any Module. It can be defined under any Sheet Code. See the Syntax below:
Syntax: Public <Variable Name> As <Variable Type>
My name is Vishwamitra Mishra. Friends Call me Vishwa. This blog is authored by me. I am an Excel Geek. Well, this blog talks a lot about my passion in Excels & Macros so I’ll not talk about it :) I am very much passionate about traveling & quite recently discovered that I am a good photographer too..:P
AND GET A FREE!
E-BOOK FOR EXCEL VBA BEGINNERS
DON'T MISS ANY NEW ARTICLE !
Get your FREE! E-Book & Have Every New Article Delivered Straight To Your Email-Box