How to get combobox not to accept user input in Ex

2020-02-10 02:30发布

Does anyone know what the properties are in the combobox that I can manipulate in order not to allow the user to key/type in any data?

3条回答
三岁会撩人
2楼-- · 2020-02-10 02:52
YourComboBoxName.Style = fmStyleDropDownList

or

YourComboBoxName.Style = 2

(that's from MS Excel Help)

查看更多
等我变得足够好
3楼-- · 2020-02-10 02:58

Here's a way to change this for each object on a worksheet:

Private Sub fixComboBoxes()
    Dim OLEobj As OLEObject
    Dim myWS As Worksheet
    Set myWS = Sheet1
    With myWS
        For Each OLEobj In myWS.OLEObjects
            If TypeOf OLEobj.Object Is MSForms.ComboBox Then

                OLEobj.Object.Style = fmStyleDropDownList
            End If
        Next OLEobj
    End With
End Sub
查看更多
三岁会撩人
4楼-- · 2020-02-10 03:05

Set the the Style of the combobox to 2 - fmStyleDropDownList. This will disallow user input, and will also prevent (combobox).value changes via macro.

查看更多
登录 后发表回答