LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default multi Loop efficiency

Per

Thanks very muchh for your help. It certainly makes the full coding
shorter. Your code works very well with one very small exception. It
makes a named range for each of the scenarios 301 -310 and the same
for the 401-410 series. I was not clear on this so I am very sorry.

I have some code that deletes all the named ranges that start with
"Test" prior to the loop begining.

I need to make one named range if the cell is either 301 or 401. One
range if it is 302 or 402.

I then want to unlock this named range, then protect the sheet so we
can enter data against 301 but no where else on the sheet.

Here is the code in its entirety if this helps.
Chad

Sub Multiloop()

Dim FoundCell As Range
Dim mys As String
Dim myint As Integer
Dim i As Long
Dim LRw As Long
Dim nm As Name

Range("bid_phase").Value = Me.cmbBidPhase.Value
Range("bid_division").Value = Me.cmbBidDivision.Value

'Remove all named ranges starting with Test, to clean sheet.

‘Remove all the names starting with Test
For Each nm In ThisWorkbook.Names
If UCase(Left(nm.Name, 4)) = "TEST" Then
nm.Delete
End If
Next nm
'First part not related to the Per LOOP
LRw = Range("W" & Rows.Count).End(xlUp).Row
If Range("bid_phase").Value = "Phase 900" Then
For i = LRw To 1 Step -1
mys = Range("W" & i).Value
Set FoundCell = Range("B:B").Find(What:=mys, LookIn:=xlValues,
LookAt:=xlWhole, MatchCase:=0)
If FoundCell Is Nothing Then
MsgBox "Not Found"
Else
myint = FoundCell.Row
' Range("B" & myint & ":" & "C" & myint).Interior.Color = vbBlue
Range("G" & myint & ":" & "U" & myint + 3).Name = "Test" & "_" &
myint
End If
Next i

'Per LOOP part where multiple ranges are created. Only one needed

Else
For X = 1 To 10
TargetVal = 300 + X
TargetVal1 = 400 + X
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 + X & ":" & "U" & myint + X).Name = "Test" &
"_" & myint + X

Next i
Next
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:39 PM.

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"