Initialize UserForm after selecting from List

tdm1103

New Member
Joined
Mar 31, 2011
Messages
19
I have an Excel Workbook, in which I have a dropdown list. I would like a userform to initialize if certain choices are selected from the list. Is this possible? And if so any help with code would be great.

Thank you.
 
I've made it a little bit closer. In the Developer tab -> Insert I have "Form Controls" and "ActiveX Controls", I was clicking the ComboBox option in Form Controls, which would give me the "DropDown". Now I need to link my list to my ComboBox. I am confused by what text should be typed where "CodeName" is? I have not named Sheet1 anything special, I am just using a dummy file with generic names to practice this. So this is what I have now:

Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)

If ActiveSheet.Sheet1 = "Sheet1" Then 
 Sheet1.ComboBox1.ListFillRange = "P1:P9" 
 Sheet1.ComboBox1.LinkedCell = "B2" 
 
End If

End Sub

In my VBA Project tree I have:
VBAProject (Userform PopUp Test.xlsm)
-Microsoft Excel Objects
--Sheet1(Sheet1)
--Sheet2(Sheet2)
--Sheet3(Sheet3)
--ThisWorkbook
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
CodeName is ok-look at your post:
-Microsoft Excel Objects
--Sheet1(Sheet1)
--Sheet2(Sheet2)
--Sheet3(Sheet3)
--ThisWorkbook
CodeName are name that are not in bracket so that is ok if yours ComboBox is in Sheet1. I told you in previous post to change combobox1 with dropdown5 everywhere in a code, because when you create your combobox excel give it that name.
I also write that you use ComboBox from ActiveX Controls it has better functionaly.
Try it, it should work.

Regards,
-JAKUZA-
 
Upvote 0
I deleted the DropDown and started over with ComboBox. That worked exactly how you said it should. Now I cannot get the combobox to populate with my list, using the code from the previous post. I'll keep playing around with it and hopefully get it to work.
 
Upvote 0
You do not get list of values in your ComboBox? Try to click to Sheet2 and then back to Sheet1 because the values are added to ComboBox when Sheet1 is activate, so you need to switch between sheets.
That is why I said it is little tricky, also I mean that if you switch two times between sheets (go to Sheet2 then to Sheet1 and again Sheet2 and back to Sheet1) you will get doubled list in ComboBox because every time the Sheet1 is activated it adds list of values.
Maybe it is better solution to put that program code in Workbook > Open instead of Workbook > SheetActivate.
Or the best solution is to put CommandButton also from ActiceX Controls which will do this and then turn itself to enabled = False so you can not press button anymore.
As you said, keep playing with it.

Regards,
-JAKUZA-
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,360
Messages
6,130,175
Members
449,562
Latest member
mthrasher16

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