Using variables across userforms

G

Genix

Please can someone help me out urgently. .

I have created 5 userforms with their respective event handlers (Private
Subs) and while creating these forms I used Public declared variables (one in
each form; all different variable Names)

Now I have created a 6th Form and want to use all five variables but VBA
keeps telling me "variable not found"

Please, is there a way to call and use variables across userforms or modules
within a single VBA project?

Thank you . .
 
R

ryguy7272

Did you declare your variable with a Dim? Are you sure the variable is
there? Are you sure it is spelled correctly?

Please post some code (the code that causes the error).

HTH,
Ryan---
 
D

Dave Peterson

You could refer to the variables by qualifying them:

Msgbox userform1.myVar1

But I find the simplest thing to do is to move those public variables to a
General module.
 
G

Genix

Dear Dave,

Thanks to all the old posts since 2005 and your input I have solved the
issue of using variables across modules and userforms. Thanks

Though I have a separate issue about ranges will post that shortly

Also thanks to HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top