PDA

View Full Version : using public variables in userforms



kieran989
03-03-2017, 08:22 PM
Is it possible to declare and set public variables such as worksheets and ranges in a module, and then refer to these in userforms?

I have declared several public integers, worksheets and ranges in a module. Then set the worksheets and ranges in the same macro that shows the userform.

The userform code still wont recognize the named ranges and worksheets?

Paul_Hossler
03-03-2017, 08:38 PM
Seems to work for me, assuming I understood the question

I have Public variables in one module, the sub to set them and show the userform in another, and the userform init puts the values into labels on the form

kieran989
03-03-2017, 11:34 PM
thanks Paul!

I realised i had set the variables after calling the userform :banghead:

Paul_Hossler
03-04-2017, 07:00 AM
That would make a difference :-)

Mark this SOLVED by using [Thread Tools] in the menu bar above your first post