nbval CellBackColor = &H80FF&

Wilder1626
Wilder1626 used Ask the Experts™
on
Hello all

I would like to be able to count the number of cell in my MSHFlexgrid1 where the cell is CellBackColor = &H80FF&

Ex: if there is 3 cells in that color, then it would tell me in a msgbox "3"

How can i do that please?

Thanks again for your help
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Try this:
Dim i As Integer, j As Integer, iCount As Integer

    iCount = 0

    For i = 1 To grdItems.Rows - 1
      For j = 1 To grdItems.Cols - 1
        grdItems.Row = i
        grdItems.Col = j
        
        If grdItems.CellBackColor = &H80FF& Then
          iCount = iCount + 1
        End If
      Next j
    Next i

    MsgBox iCount

Open in new window

Thank you so much. This is perfect.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial