我正在尝试为作为参数传递给函数的单元格着色,但它似乎不起作用。这是代码:
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
不是一个范围?有什么想法吗?