如何在以下代码中直接添加或编辑组合框值?在组合框中编写文本时,显示错误“ worksheetfunction”,并且我无法添加新代码。
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
答案 0 :(得分:0)
要将新项目添加到组合框列表:
在此示例中,组合框“ ComboAdd”在表单上,并链接到“ F”列中的数据:
将NewValueRange设置为字符串 NewValueRange =“ F”&Range(“ F1048576”)。End(xlUp).Row + 1 Range(NewValueRange)= UserForm1.ComboAdd.Value