这不是答案,但在测试中对代码进行了重新调整并添加了一些内容,但其本质仍然是您的,并且运行良好。
Function ERP_Lamp(strFixture As String) As String
Dim t(3) As String
Dim c(3) As String
t(1) = "1x4 1l"
t(2) = "1x4 1l basket"
t(3) = "1x4 2l"
'CFL
c(1) = "can- 1 4 pin"
c(2) = "can- 2 2 pin"
c(3) = "can- 2 4 pin"
strFixture = LCase(strFixture)
For i = 1 To 3
If InStr(strFixture, LCase(t(i))) >= 1 Then
ERP_Lamp = "Linear Fluorescent"
Exit For
ElseIf InStr(strFixture, LCase(c(i))) >= 1 Then
ERP_Lamp = "Compact Fluorescent"
Exit For
End If
Next i
Erase t
Erase c
End Function