My Combobox wont update with new values

eawachte

New Member
Joined
Jan 14, 2011
Messages
29
I have code that on a button_Click() a range of data is copied and pasted into a database. Once this data is pasted to the data base it updates a column (B150:B1000) that are the reference cells for my combobox in a userform gui.

My issue is that the combobox does not update with the new values i enter into the database unless I close the sheet and reopen the sheet. This is a major inconvenience for users.

Below is my code for the combobox, any help with how to update the combobox would be greatly appreciated!!

Private Sub ComboBox1_dropbutt*******()

If ComboBox1 = blank Then
For i = 151 To 161
ComboBox1.AddItem Sheets("Geometry").Cells(i, 2)
Next
End If
End Sub
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
You could repopulate your combobox within the button_Click() procedure after you copy\paste the data.

Alternatively, instead of using the .Add method to populate the ComboBox, you could set .RowSource property e.g.

Code:
Private Sub UserForm_Initialize()
    ComboBox1.RowSource = "Sheet1!B150:B1000"
End Sub
If you define the ComboBox1.RowSource, then any change to the cells in B150:B1000 will change the combobox.
 
Upvote 0
Thank you for the help!! That seems to work perfectly

I also am having an issue clearing a textbox value after a commandbutton is hit. I have been able to write in "userform".Combobox1.Clear and successfully cleared the combobox, but with the same logic on a textbox

"userform".Textbox1.Clear the function does not work. I do not get the .clear option and when i type it anyway it returns an error.

These are the 2 main issues with my project remaining, thank you so much for the help

Gene
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,790
Members
451,589
Latest member
Harold14

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