referencing a variable from a form in a module

M

Matthew Dyer

I have a form with 4 different text boxes in a form. When a command
button is pressed on the form, the values are saved into variables
that I want to use in a module sub saved in the same excel workbook,
but i seem to be striking out... How do i accomplish this?
 
B

B Lynn B

Dim the variables as public in the declarations section of any module. e.g....

Public myInt as Integer
Public myStr as String, myWksh as Worksheet
etc...

This allows whatever is stored in them to be retained beyond the execution
of a specific module that is assigning values to them.
 
M

Matthew Dyer

Dim the variables as public in the declarations section of any module. e.g....

Public myInt as Integer
Public myStr as String, myWksh as Worksheet
etc...

This allows whatever is stored in them to be retained beyond the execution
of a specific module that is assigning values to them.





- Show quoted text -

I figured out my problem. My variable had the same name as the text
box in my user form. Switched it around and it's working perfectly!
 

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