Dynamically reference framename from a single cell string value

piers_morgan

New Member
Joined
Sep 3, 2003
Messages
20
Hello. I'm afraid I have been searching a very long time but cannot find the solution.

I have a userform with several frames. The frame names are stored in a worksheet table. When the userform is open, if the user selects a dropdown the worksheet table updates a single cell. Inside this cell is the name of the frame that should be brought to a specific location in the userform.

Or to explain more simply, this bit of hard-coded code will work:
userform1.frame1.top = 210

This code will work fine too for frame2:
userform1.frame2.top = 210

For frame 3, etc...
userform1.frame3.top = 210

But what if sheet1 cell A1 changes to frame1, frame2, frame3, etc? What code will dynamically change the "hard" code? For example, something like:
userform1.sheet1("a1").value.top = 210

Thanks for the help!
Piers.
ps, this is to avoid potentially hundreds of "if this then" commands, so appreciate if this is not part of the answers :eek:)
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
you could try:

Code:
userform1.controls(sheet1.range("a1").value).top = 210

Untested though ...

WBD
 
Upvote 0
wideboydixon, thanks so much! It worked and is so very straight-forward. It adds such a massive amount of power to a userform that needs to be dynamic, that I can't believe I couldn't find results of the same situation in a morning of searching.

Let's hope it helps someone else. Thanks again.
 
Upvote 0

Forum statistics

Threads
1,216,581
Messages
6,131,546
Members
449,654
Latest member
andz

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