我正在嘗試將作爲參數傳遞給函數的單元格着色,但似乎不起作用。以下是代碼:無法爲函數內的單元格區域着色
Sub my_test(Target As Range)
With Target.Cells(1, 1).Interior
.ColorIndex = 3
.PatternColorIndex = xlAutomatic
End With
End Sub
Function f_Lookup_domain(P_Cell_name As Range, ByVal P_Default As String) As String
Call my_test(P_Cell_name)
v_Cell_name = P_Cell_name.Value
' Application.Volatile
'Lookup the domain of a signal from the cell name
'
v_temp = Application.VLookup(v_Cell_name, Range("n_IO_cell_lookup"), 2, False)
If Application.IsError(v_temp) Then
' cell given is not a real IO cell, try to use default
If P_Default = "CUT" Then
v_temp = "Unknown"
Else
v_temp = P_Default
End If
End If
f_Lookup_domain = v_temp
End Function
沒有錯誤報告,函數返回正確的值。 my_test
被調用,但單元格未被繪製。如果我叫my_test
用下面的測試平臺:
Sub Testbench()
Call my_test(Range("D10"))
End Sub
它做顏色的細胞正常。好像P_Cell_name
不是一個範圍?任何想法的人?
以防萬一它的相關 - 這裏是我如何稱爲功能:= f_Lookup_domain(E17,D16) –