我正在試圖根據函數中給定的參數在不同的工作表上執行VLOOKUP。我已經玩了好幾個小時了,不知道爲什麼它不起作用。我儘可能多地減少了代碼,但無法有效地找到解決方案。我認爲這可能是我如何從VLOOKUP的其他工作表調用範圍的問題。代碼如下。請指教。如果我不清楚我要問什麼,我會提供反饋。謝謝Excel VBA - 自定義函數; #VALUE錯誤;在不同的工作表上的VLOOKUP
Function GraphDataA(cR As String, time As String, aClient As String, tps As String, dat As String)
Dim client As Boolean
Dim day As Boolean
Dim tot As Boolean
Dim dayTotData As Range
Dim dayTotDatas As Worksheet
Set dayTotDatas = ActiveWorkbook.Sheets("DayTot")
Set dayTotData = dayTotDatas.Range("A3:AI168")
client = False
day = False
tot = False
If date = "" Then
GraphDataA = ""
End If
If aClient = "" Then
GraphDataA = ""
End If
If cR = "Client" Then
client = True
End If
If time = "Day" Then
day = True
End If
If tps = "Total" Then
tot = True
End If
If client = True Then
If day = True Then
If tot = True Then
GraphDataA = WorksheetFunction.VLookup(aClient, dayTotData, WorksheetFunction.Match(dat, dayDate, 0) + 8, _
False)
End If
End If
End If
End Function
步通過代碼 –