?
Solved

why does this sub give error

Posted on 2013-12-21
5
Medium Priority
?
204 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 49

Expert Comment

by:Martin Liss
ID: 39733917
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
ID: 39733926
Thanks MartinLiss
that gives the same error
this is highlighted:
Next r
0
 
LVL 49

Accepted Solution

by:
Martin Liss earned 2000 total points
ID: 39733933
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
ID: 39733936
thanks MartinLiss, learn something new everyday
glad you are there
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 39733939
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month9 days, 4 hours left to enroll

765 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