.ListFillRange Activex ComboBox中需要的对象

时间:2019-12-09 21:23:42

标签: excel vba combobox activexobject

'我正在使用Activex ComboBox,当您从ComboBox中选择一个选项时,我想做的就是向某些单元格插入数据验证列表并设置格式,但是它显示“对象错误(424)”在.ListFillRange行。

这是我的代码:

Private Sub ComboBox1_Change()

Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Sheet1")

Dim HW As Range, Deploy2 As Range, Options As Range
Set HW = ws.Range("B2:B105")
Set Deploy2 = ws.Range("G12:H12")
Set Options = ws.Range("A1:A3")

With ComboBox1
.ListFillRange = ("= Options")
End With

If ComboBox1 = "1" Then

With Deploy2.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Formula1:="='" & ws.Name & "'!" & HW.Address
End With

With Worksheets("Sheet1")
.Range("G12:H12").Merge
.Range("G11:H13").BorderAround , ColorIndex:=xlAutomatic, Weight:=xlMedium
.Range("G12:H12").Interior.Color = RGB(226, 107, 6)
.Range("G12:H12").WrapText = True
End With

Columns("G:H").ColumnWidth = 13.5
Columns("I").ColumnWidth = 6.9
Columns("J:O").ColumnWidth = StandardWidth

Rows("12").RowHeight = 36.5
Rows("11").RowHeight = 15.5
Rows("13").RowHeight = 15.5
End If

End Sub

0 个答案:

没有答案