How to add or edit combo box values directly in following code? When writing a text in a combo box, show error "worksheetfunction" And I can not add a new code.
Private Sub UserForm_Click()
Dim xRg As Range
Private Sub UserForm_Initialize()
Set xRg = Worksheets("Sheet1").Range("A2:B8")
Me.ComboBox1.List = xRg.Columns(1).Value
End Sub
Private Sub ComboBox1_Change()
Dim xRg As Range
Set xRg = Worksheets("Sheet1").Range("A2:B8")
Me.TextBox1.Text = Application.WorksheetFunction _
.VLookup(Me.ComboBox1.Value, xRg, 2, False)
End Sub
To add new items to a combo box list:
In this example, the combo box "ComboAdd" is on a form and is linked to data in "F" column:
Dim NewValueRange As String NewValueRange = "F" & Range("F1048576").End(xlUp).Row + 1 Range(NewValueRange) = UserForm1.ComboAdd.Value
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.