Solved

why does this sub give error

Posted on 2013-12-21
5
203 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 47

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 47

Accepted Solution

by:
Martin Liss earned 500 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 47

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 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