LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Loop through ranges

I have some code that runs down Rows 10-377, and it ranges in column
from K to R. The rows always stay the same but the columns need t
advance to the right. The way I have it now is repeating all of th
same code for new range.
I already have a for statement looks like this:

For i = 1 To 377
For Each cell In Rows(i).Columns("K:AA")
Set rng = Nothing
If cell.Value = "QAPK" Then
Set rng = cell 'y ??
Exit For
End If

next sub:
For i = 1 To 377
For Each cell In Rows(i).Columns("AI:AJ")
Set rng = Nothing
If cell.Value = "QAPK" Then
Set rng = cell 'y ??
Exit For

The only difference is the new column names.

How can I tell it to loop through multiple ranges without creating
new sub?

Thank

--
Message posted from http://www.ExcelForum.com

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find loop doesn't loop JSnow Excel Discussion (Misc queries) 2 June 24th 09 08:28 PM
Worksheet_Change - loop within a loop bgm Excel Programming 1 January 19th 04 01:27 PM
How to loop through all ranges in a worksheet Nanette[_2_] Excel Programming 6 January 12th 04 07:30 PM
loop to name ranges spence[_3_] Excel Programming 1 January 8th 04 05:16 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 01:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"