PDA

View Full Version : highlight activecell in combo box



wilg
01-23-2012, 05:50 PM
Hi, how do I highlight the activecell's value to hit delete to clear contents when combo box initializes?

I have this which initializes the combo box with the value but I want it to highlight so if I key delete it will clear the cell.

Private Sub UserForm_Initialize()
ComboBox1.RowSource = "COMPLETE_NAME"

With ComboBox1
.SelStart = 0
.SelLength = Len(ComboBox1)
End With
ComboBox1.Value = ActiveCell.Value


End Sub

Sebastian H
01-23-2012, 11:06 PM
Assign the Value before you assign SelLength.

wilg
01-24-2012, 05:31 PM
Got it, after trying various positions this works.

Private Sub UserForm_Initialize()
ComboBox1.RowSource = "COMPLETE_NAME"
ComboBox1.Value = ActiveCell

With ComboBox1
.SelStart = 0

.SelLength = Len(ComboBox1)

End With
End Sub


Thanks very much Sebastian.