How to get combobox not to accept user input in Excel-Vba?

前端 未结 3 635
星月不相逢
星月不相逢 2020-12-16 12:14

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条回答
  •  醉话见心
    2020-12-16 12:44

    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
    

提交回复
热议问题