我有這樣的代碼:爲什麼這種類型不匹配?
Public Function MultiVLookup(MatchWith As String, TRange As Range, col_index_num As Integer)
If (MatchWith = "") Then
MultiVLookup = ""
Else
For Each cell In TRange
a1 = cell.Value
a2 = CStr(a1) 'FAILURE IN THIS LINE
b = CStr(MatchWith)
If (a2 = b) Then
x = x & cell.Offset(0, col_index_num).Value & ", "
End If
Next cell
If (x = "") Then
MultiVLookup = ""
Else
MultiVLookup = Left(x, Len(x) - 2)
End If
End If
End Function
,我這樣稱呼它:
L_CurrentService = MultiVLookup(L_CurrentCI, Sheets("Servicios").Columns("C"), 2)
但它與類型不匹配上面標明線路發生故障時,我不設法找到原因。
爲什麼我不能像這樣調用CStr()?
a1是什麼類型?呼叫類型名稱: MsgBox TypeName(a1) – Rob