counting cells in mshflexgrid with cell's color (invalid row error)

Posted on 2006-05-25
Last Modified: 2010-04-17
I get invalid row error in the line below.Please help

Dim T1counter
Dim T2lcounter
T1 = 0
T2 = 0

Dim mycounter
For mycounter = 1 To MSFlexGrid1.Rows
    MSFlexGrid1.row = mycounter  <-----------------------invalid Row value error?
    MSFlexGrid1.col = 5
If MSFlexGrid1.CellForeColor = vbCyan Then
 If MSFlexGrid1.Text = "T1" Then
   T1 = T1 + 1
 End If
 If MSFlexGrid1.Text = "T2" Then
   T2 = T2 + 1
 End If
End If

Next mycounter

Thank you.
Question by:Aiysha
    LVL 44

    Accepted Solution

    Hi Aiysha,

    when do you get that error on the first counter or on the end try using

      For i = 1 To MSFlexGrid1.Rows - 1

      Next i

    this worked here for me, the grid starts counting at row 0 so if you have a header row which is 0 and 10 normal rows rows element has 11 rows but you need to fill 10 rows so rows - 1

    share what you know, learn what you don't

    Author Comment

    it works fine thank you.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Suggested Solutions

    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now