Getting cell Interior Color Fails when range passed from Worksheet function

后端 未结 2 1457
离开以前
离开以前 2021-01-16 06:51

I am trying to get write a simple function one can call from a cell that would return if the background of a given cell has a specific background color.

This functio

2条回答
  •  深忆病人
    2021-01-16 07:51

    RGB is calculated by VBA itself and you don't need to assume it is an array, it is a long integer in fact so if you want to check the background color of a cell you can just simply do this which will work on the worksheet too:

    Public Function IsColor(Rng As Range, R As Integer, G As Integer, B As Integer) As Boolean
        If Rng.Interior.Color = RGB(R, G, B) Then
            IsColor = True
        Else
            IsColor = False
        End If
    End Function
    

提交回复
热议问题