Solved

why does this sub give error

Posted on 2013-12-21
5
197 Views
Last Modified: 2013-12-21
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 ?
0
Comment
Question by:isnoend2001
  • 3
  • 2
5 Comments
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
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
 

Author Comment

by:isnoend2001
Comment Utility
Thanks MartinLiss
that gives the same error
this is highlighted:
Next r
0
 
LVL 45

Accepted Solution

by:
Martin Liss earned 500 total points
Comment Utility
Your Next c and Next r should be reversed. And you actually don't need the r and c at all, just Next.
0
 

Author Closing Comment

by:isnoend2001
Comment Utility
thanks MartinLiss, learn something new everyday
glad you are there
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

772 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

13 Experts available now in Live!

Get 1:1 Help Now