Forum Discussion
How to transfer values from multiple comboboxes from 1 userform using a commandbutton to a cell
I am trying to create a userform that has 5 comboboxes that are dependent on each other and once all fields are selected the user would press the commandbutton and the information in each box will populate in a cell of my choosing.... Example
on userform
Combobox1 = "States"
Combobox2 = "County"
Combobox3= "City"
etc...
after pressing the commandButton1. The values "State", "County", City go into cells that I specify....Example
"State" to D6
"County" to F12
"City" to B4
I have been at this all day and can't find anything that will let me randomly do this from a userform, commandButton from comboBoxes. Any help would be great.
- Matt MickleBronze Contributor
Eduardo-
I believe you can accomplish your task by completing the following :
Create a command button on your userform. Link it to this sub procedure:
Private Sub CommandButton1_Click() Dim sht As Worksheet
'This is where you specify the sheet to put the UserForm Values.... Set sht = Sheets("Sheet1") With sht .Range("D6") = Me.ComboBox1.Value .Range("F12") = Me.ComboBox2.Value .Range("B4") = Me.ComboBox3.Value End With End SubWhen you click the command button it will move the values from your userform to the worksheet you specify.
- Eduardo RiveraCopper Contributor
THANK YOU!!!! I have tried this code before and it didn't work.... but since I now know I'm not crazy I rebuilt my spreadsheet and it worked. Don't know why it was messed up but it wasn't working soooooo start from scratch. thanks again!!!
- Matt MickleBronze Contributor
Eduardo-
Glad you were able to get it working! If you need more help feel free to post back to the community for more support. There are a lot of smart people on this forum that are always happy to help!