VBA Form Name Object Variable

mrlemmer11

New Member
Joined
Jun 8, 2015
Messages
32
Hi All,

First post here.

I've spent 3 hours trying to figure this out and just can't do it.

Basically I have a UserForm in WORD VBA with the Excel Reference added onto it. I have named my UserForm under properties (Name) to formStage1.

Now I have a whole bunch of command buttons and which saves the data from their related text fields to different variables.... this all works. However, I'm trying to be mindful to the fact that I may want to change my (Name) from formStage1 to formStage37 one day.... and if I do that, I would need to go into my code and change all of my strEdition = formStage1.boxEdition to strEdition = formStage37.boxEdition ..... which would be a big pain

I've tried so many ways to declare oForm1 publicly outside of any Subs and then set it using set oForm1 = UserForms.Add(formStage1) and about 100 different things.... and I can't get it to work.

Any Help? Thanks everyone!
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Something like:
Rich (BB code):
Dim oForm As formStage1
'...
Set oForm = formStage1

Is there a particular reason you chose not to put the code in the userform? It then doesn't matter what its name is
 
Upvote 0
Something like:

Is there a particular reason you chose not to put the code in the userform? It then doesn't matter what its name is

Could you explain this a little bit more?

-----

Kyle123,

Thanks you so much. It worked. I understand general programming theory, how functions, arrays, etc work. I can review code and made it work for me after trial and error.... it's much longer than a proficient programmer, but it eventually gets done.

I do run into problems when referencing objects and how they work exactly. I should prob spend some time researching that and get a better understanding.
 
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,539
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top