Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

modules in VB and VBA

Status
Not open for further replies.

yoyoyojohnny

Technical User
Nov 3, 2003
9
CA
Hi all,
I need some little help with the modules in VBA.
I have some background with VB and there I was Dim-ming the variables that should keep their current value when changed by different events (buttons clicked, etc.). I now want to dimension some variables in a module in an Excel file and give them starting values and keep changing them with events in worksheets, but it does not work.
In the module code I write just this:

Dim intRow, intCol as Integer
intRow = 2
intCol = 2

And with the button in the worksheet I want to add values in the worksheet so that the intRow variable keeps changing (intRow = intRow +1).
Please help.
 
...Dim intRow, intCol as Integer...

Change to
[blue]
Code:
   Public intRow as Long, intCol as Integer
[/color]

The way you have it, intRow is defined as Variant (Variant is the default) and the scope is current module only (Dim vs. Public).

Also, since the maximum value for an int is 32,767 it is best to use the Long type for variables that will hold row numbers.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top