VBA userform to return variable for another sub

Marmit424

Board Regular
Joined
Jul 12, 2016
Messages
58
Hi,

In a set of code, I have several variables tied to arrays. Ex:
- Color1 = Array(23,42,45)
- Color2 = Array(43,23,67)

Separately, I would like to enable others to choose between Color1 and Color2 if they want to, but not have to mess with any code and not have to select the color every time. To that end, I'm trying to build a userform that allows them to select which color they would like. My problem is that the users selection gets returned as a string "Color2" which no longer pulls the array.

So essentially I'm curious if there is either a way to get userform controls to return Color2 rather than "Color2". If not, is there another way to do this I'm not considering?

Thanks!
 
Last edited:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Quick update!

I realized that I could nest the user returned value in an if statement to get around this. For instance:
If UserInput = "Color1" Then
SelectedTheme = Color1

Problem solved!
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

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