why does this sub give error

this code gives invalid next control reference
Sub ReSetForColorFlexStatus() 'set the forcolor flexstatus from red to blue
     Dim r As Integer
     Dim c As Integer
     With flexStatus
    For r = 1 To .Rows - 1
    For c = 0 To .Cols - 1
    .CellForeColor = vbBlue
    Next r
    Next c
    End With
End Sub

Open in new window

what is wrong ?
isnoend2001Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Martin LissConnect With a Mentor Older than dirtCommented:
Your Next c and Next r should be reversed. And you actually don't need the r and c at all, just Next.
0
 
Martin LissOlder than dirtCommented:
Sub ReSetForColorFlexStatus() 'set the forcolor flexstatus from red to blue
     Dim r As Integer
     Dim c As Integer
     With flexStatus
    For r = 1 To .Rows - 1
    For c = 0 To .Cols - 1
   .Row = r
   .Col = c
    .CellForeColor = vbBlue
    Next r
    Next c
    End With
End Sub

Open in new window

0
 
isnoend2001Author Commented:
Thanks MartinLiss
that gives the same error
this is highlighted:
Next r
0
 
isnoend2001Author Commented:
thanks MartinLiss, learn something new everyday
glad you are there
0
 
Martin LissOlder than dirtCommented:
Thank. I'm glad I was able to help.

Select the 'About Me' tab in my profile and you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2013
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.