0
我有以下VBA函数:Excel的VBA:返回计算结果的单元格值
Function IndexOfColor(InRange As Range, ColorIndex As Long) As Excel.Range
Dim R As Range
Application.Volatile True
If IsValidColorIndex(ColorIndex) = False Then
IndexOfColor = 0
Exit Function
End If
For Each R In InRange.Cells
If R.Interior.ColorIndex = ColorIndex Then
IndexOfColor = R
Exit Function
End If
Next R
IndexOfColor = 0
End Function
在我的excel表,我称之为:
=IndexOfColor(D15:M24,37)
,一定可以得到"#VALUE"
。我已经调试过该功能,直到最后,并且没有问题。虽然这应该只返回1结果(我正在查看范围,并且只有一个彩色单元格),但我也尝试将此数组结果(CTRL-SHIFT-ENTER)。
对此提出建议?
什么是CI取代
Variant
?它不应该是'ColorIndex'吗? – 2012-08-16 13:05:47'虽然这应该只返回1结果'也是'1'你是如何到达的?该函数应该返回一个范围')作为Excel.Range'?也许如果你能够准确地解释你想做什么? – 2012-08-16 13:07:49
我看到你的函数定义了两个参数'InRange'和'ColorIndex',但我看到你用3个参数调用函数'D15:M24','37'和'0' – SeanC 2012-08-16 13:10:01