请教,Excel2003中,如何在VBA中使用列表框或组合框?

2024-12-02 23:35:17
推荐回答(1个)
回答(1):

Private Sub ComboBox1_Change()
Dim A
A = ComboBox1.Text '赋值给变量
End Sub

Private Sub ComboBox1_GotFocus()
Dim I As Long
ComboBox1.Clear
For I = 1 To UsedRange.Rows.Count
ComboBox1.AddItem Range("A" & I).Value '添加到combox
Next
ComboBox1.ListIndex = 0 '选中第一项
End Sub