0
我不知道爲什麼這是拋出一個編譯錯誤,並告訴我,我有一個沒有如果。錯誤在ElseIf行上。其他一切似乎都在起作用。有什麼建議麼?否則沒有編譯錯誤
If IsEmpty(Me.ComboBox15.Value) = False Then
strFind = Me.ComboBox15.Value 'what to look for
With Ws.Range("cGroup") 'where to look
Sheet2.ListObjects("Table1").Range.AutoFilter Field:=1, Criteria1:=ComboBox15.Value
Set c = .Find(strFind, LookIn:=xlValues)
'c.Select
If Not c Is Nothing Then
With Me
.ComboBox15.Value = c.Offset(0, 0).Value
.ComboBox16.Value = c.Offset(0, 1).Value
.ComboBox17.Value = c.Offset(0, 2).Value
.ComboBox1.Value = c.Offset(0, 3).Value
.ComboBox19.Value = c.Offset(0, 4).Value
r = c.Row
f = 0
End With
FirstAddress = c.Address
Else: MsgBox strFind & "Not listed" 'search failed
End If
ElseIf IsEmpty(Me.ComboBox16.Value) = False Then
strFind = Me.ComboBox16.Value 'what to look for
With Ws.Range("cGeography") 'where to look
Sheet2.ListObjects("Table1").Range.AutoFilter Field:=2, Criteria1:=ComboBox16.Value
Set c = .Find(strFind, LookIn:=xlValues)
'c.Select
If Not c Is Nothing Then
With Me
.ComboBox15.Value = c.Offset(0, -1).Value
.ComboBox16.Value = c.Offset(0, 0).Value
.ComboBox17.Value = c.Offset(0, 1).Value
.ComboBox1.Value = c.Offset(0, 2).Value
r = c.Row
f = 0
End With
FirstAddress = c.Address
Else: MsgBox strFind & "Not listed" 'search failed
End If
End With
ElseIf Not IsEmpty(Me.ComboBox17.Value) Then
strFind = Me.ComboBox17.Value 'what to look for
With Ws.Range("cDept") 'where to look
Sheet2.ListObjects("Table1").Range.AutoFilter Field:=3, Criteria1:=ComboBox17.Value
Set c = .Find(strFind, LookIn:=xlValues)
'c.Select
If Not c Is Nothing Then
With Me
.ComboBox15.Value = c.Offset(0, -2).Value
.ComboBox16.Value = c.Offset(0, -1).Value
.ComboBox17.Value = c.Offset(0, 0).Value
.ComboBox1.Value = c.Offset(0, 1).Value
r = c.Row
f = 0
End With
FirstAddress = c.Address
Else: MsgBox strFind & "Not listed" 'search failed
End If
End With
Else: MsgBox "Error"
End If
對於任何格式/縮進錯誤,我表示歉意。我是VBA的全新人物。我搜索了答案,但是我發現的所有內容都是這樣的。
爲此如果要關閉與如果不是C是沒有開始塊。然後(對不起,我無法弄清楚如何格式化)。我試圖刪除它,以防萬一,但我仍然得到相同的錯誤。 @Soren – aearce2000
你說得對。那不是。我已經更新了我的答案。 –
這樣做!非常感謝!! – aearce2000