Skip some part of For-Each Loop

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
1,953
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
This is some code I'm writing
VBA Code:
  Set iRange = .Range("A" & ThisRow & ":" & HiCol & ThisRow)
                For Each Cel In iRange
                    Set Access = New clsAccess
                    If CRCol(iSheet, Cel) = True Then
                            Match = Access.CR(Cel)
                            ' at this point we want loop to jump to Cell CQ
                        Else
                            Match = Access.cfrm(Cel)  'Returns true or false if cell matches db
                    End If
                    If Match = False Then Stop:  'To Do
                Next
In the line remmed what would be a good approach? I need to skip any cells before CQ.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Do you mean column CQ? If you want to skip cells before column CQ then define iRange to include only columns starting from CQ.
VBA Code:
If HiCol < 95 Then HiCol = 95
You're not showing us a complete picture here, so I'm guessing at what you want to do. I don't know what you mean by "jump to Cell CQ" in the context of where you put that comment.

The only other guess I have for you is
Rich (BB code):
                            If Cel.Column >= 95 Then
                               Match = Access.CR(Cel)
                               ' at this point we want loop to jump to Cell CQ
                            End If
 
Upvote 0
Yes it is Column CQ, I'm iterating through the range until a certain point when I want to skip some, then continue.
That point will vary.
I'll try a For-Next Loop and increment the loop counter.
 
Upvote 0
Yes, the latter. Incrementing the counter to skip some did work. Some columns represent weeks. How many weeks varies. If the last is before
CQ , say it was BD I don't need to look at Cols BE-CP but do want to continue reading Values from CQ.
 
Upvote 0

Forum statistics

Threads
1,221,498
Messages
6,160,161
Members
451,627
Latest member
WORBY10

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top