EXCEL VBA组合框中添加新的选项,

2024-11-22 21:55:55
推荐回答(2个)
回答(1):

Private Sub ComboBox1_Click()
    [A1] = ComboBox1.Text  '赋值到单元格
End Sub
Private Sub UserForm_Initialize()
    ComboBox1.AddItem "AAAA"   '添加
    ComboBox1.AddItem "BBBB"
    ComboBox1.AddItem "CCCC"
End Sub

回答(2):

SubMyList()
DimRngAsRange
SetRng = Cells(1, 1)
WithRng.Validation
.Delete
.Add Type:=xlValidateList, Formula1:="字段1,字段2,字段3,..."
EndWith
SetRng =Nothing
EndSub