Excel:获取单元格颜色

1)如何使用Excelmacros获取单元格的颜色? 我无法得到这个function的工作:

Sub BGCol(MRow As Integer, MCol As Integer) bgColor = Cells(MRow, MCol).Interior.ColorIndex End Sub 

2)在单元格x,y我想要有下面的公式:

=BGCol(x,4)

那么如何获得当前的行索引呢?

你应该使用一个function:

 Function BGCol(MRow As Integer, MCol As Integer) As Integer BGCol = Cells(MRow, MCol).Interior.ColorIndex End Function 
 Function GetColor(Mycell As Range) GetColor = Mycell.Interior.ColorIndex End Function 

:::使用公式:: = getcolor(x4)