ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   combobox doesn't load cell value at startup (https://www.excelbanter.com/excel-programming/403127-combobox-doesnt-load-cell-value-startup.html)

Charlie

combobox doesn't load cell value at startup
 
I've got my combobox to apply the change made to it immediately with:
Private Sub ComboBox1_Change()
Worksheets("sheet1").Range("C16") = Me.ComboBox1.Value
End Sub
....and I leave the controlsource empty

But now, when the form loads, it doesn't load the cell value back into the
combobox, it's just blank... How do I adjust this?


merjet

combobox doesn't load cell value at startup
 
Private Sub UserForm_Initialize()
If Worksheets("sheet1").Range("C16") < "" Then
For Each c In Range(ComboBox1.RowSource)
If c = Worksheets("sheet1").Range("C16") Then
ComboBox1.Value = c
Exit Sub
End If
Next c
End If
End Sub

Hth,
Merjet



All times are GMT +1. The time now is 12:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com