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: 49
Default multi Loop efficiency

Hi

I was looking for a more efficient way to loop through a number of job
codes.

They go from 301 to 310 and 401 to 410. I am repeating the same code
10 times to get the job done and I was hoping someone could help with
a more efficient method. Problem is I have to increment the name
range by 1 each time.

I only included 2 loops for demonstration purposes.

Thanks in advance
chad

Sub Multiloop()

Dim i As Long
Dim LRw As Long


If Range("AAA").Value = "Phase 301" Or Range("AAA").Value = "Phase
401" Then
LRw = Range("Y" & Rows.Count).End(xlUp).Row
For i = LRw To 1 Step -1
mys = Range("Y" & i).Value
Set FoundCell = Range("C:C").Find(What:=mys, LookIn:=xlValues,
LookAt:=xlWhole, MatchCase:=0)
myint = FoundCell.Row 'Name range increment
Range("G" & myint + 1 & ":" & "U" & myint + 1).Name = "Test" &
"_" & myint + 1
End If
Next i

‘REPEAT CODE * 10 (NOT THAT EFFICIENT).

ElseIf Range("AAA").Value = "Phase 302" Or Range("AAA").Value =
"Phase 402" Then
LRw = Range("Y" & Rows.Count).End(xlUp).Row
For i = LRw To 1 Step -1
mys = Range("Y" & i).Value
Set FoundCell = Range("C:C").Find(What:=mys, LookIn:=xlValues,
LookAt:=xlWhole, MatchCase:=0)
myint = FoundCell.Row 'Name range increment
Range("G" & myint + 2 & ":" & "U" & myint + 2).Name = "Test" &
"_" & myint + 2
Next i

End If

End sub
 
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
How to loop through multi-selection listbox? dan dungan Excel Programming 17 April 25th 08 10:14 PM
efficiency Carlee Excel Programming 3 September 24th 07 09:14 AM
Do..Loop in multi sheets norika Excel Programming 7 May 26th 05 07:44 AM
VBA Efficiency Question Brian Excel Programming 4 March 26th 05 04:10 PM
.select efficiency Lawlera Excel Programming 4 February 4th 04 02:38 PM


All times are GMT +1. The time now is 10:19 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"