How to find the cell background color

2.8k views Asked by At

Using Flexgrid

I want to check the background color of the particular cell...

Code

if flexgrid1.TextMatrix(1, 2).CellBackColor = vbCyan then
msgbox vbcyan
else
msgbox vbwhite
End if

The above code is showing error as "Invalid Qualifier"

Other way....

if flexgrid1.row = 1 and flexgrid1.col = 2 and  .CellBackColor = vbCyan then
    msgbox vbcyan
    else
    msgbox vbwhite
    End if

The above code not displayed message box

How to solve the problem...

What wrong in my code.

2

There are 2 answers

0
C-Pound Guru On BEST ANSWER

.CellBackColor gets/sets the color for the current .Row/.Col, so before asking, you have to set the .Row/.Col to the one you're looking at:

With flexgrid1
   .Row = 1
   .Col = 2
   If .CellBackColor = vbCyan Then
      msgbox vbCyan
   Else
      msgbox vbWhite
   End If
End With 
2
ChrisPadgham On

are your msgbox statements kosher? msgbox takes a string as its argument.

msgbox "colour is Cyan"