我在Excel中有一本主要工作簿和一本子书。我在两本工作簿上都有我的用户表单。这里的问题是,我在主书中打开用户表单,并通过该用户表单打开这个子书。我成功完成了;我有一个组合框用于搜索:所以它有时会向我显示错误:
type missmatch:
这是我的代码:
Private Sub
ComboBox2.DropDown
Sheets(1).Select
Application.Goto "R1C1"
Dim r As Range, v() As Variant, s() As String
'Set r = Range("InSheetDropDownList")
Set r = Worksheets("Sheet1").Range("A2", _
Worksheets("Sheet1").Range("A" & Rows.Count).End(xlUp))
v() = WorksheetFunction.Transpose(r)
On Error Resume Next
With ComboBox2
If .Value = "" Then .List = v()
s() = Filter(WorksheetFunction.Transpose(.List), .Text, True, vbTextCompare)
If UBound(s) = -1 Then
.Text = ""
Else
.List = WorksheetFunction.Transpose(s)
End If
End With
'ComboBox2.DropDown
End Sub