Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default loops and If's

I'm still learning about loops and If statements.



I am matching two IF conditions and then return a value (per).



I am trying to work out how to speed up the code. As Once it reaches "per =
ShirePer" line I wan it to go to the next step in the macro. Currently it
finds the correct value but then proceeds to check the next r until rnumrows
occurs.



How do you speed this up? Any directions would be appreciated.





Thanks in advance



David



---------



Sub dummy()

For y = 1 To 7

ZnumRows = Worksheets("Zones Raw Data").UsedRange.Rows.Count - 8



For zr = 1 To ZnumRows

With Worksheets("Zones Raw Data")

ZoneCatch = .Cells(8 + zr, (2 * y))

Zoneshire = .Cells(8 + zr, (2 * y) + 1)

End With





'STEP 2



'Get Shires %

col = Worksheets("Zone Definitions").Range("f2")



rnumrows = Worksheets("Area %").UsedRange.Rows.Count - 8





For r = 1 To rnumrows



With Worksheets("Area %")

'shireCatch =Catchment name

PerCatchName = .Cells(8 + r, 1 + (col - 1) * 3)

'ShireName% = name of shire in the catchment

ShireNamePer = .Cells(8 + r, ((col * 3) - 1))

'Shire % = % in that shire in that catchment

ShirePer = .Cells(8 + r, col * 3)

End With





'Find matching percentage



If ZoneCatch < 0 Then

If ZoneCatch = PerCatchName Then

If Zoneshire = ShireNamePer Then

per = ShirePer





End If

End If

End If



Next r

'next stage of the calculations





Next zr

Next y


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default loops and If's

Sorry for the trouble I just found out how to do it.
I just needed a Exit For statement


If ZoneCatch < 0 Then
If ZoneCatch = PerCatchName Then
If Zoneshire = ShireNamePer Then
per = ShirePer
Exit For
End If
End If
End If


Reply
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
Loops [email protected] Excel Discussion (Misc queries) 2 October 14th 06 02:52 PM
For next loops Kate Excel Discussion (Misc queries) 5 May 22nd 06 01:11 PM
Do loops grandfilth Excel Discussion (Misc queries) 1 November 10th 05 12:00 AM
Loops etc. Jonathan Vickers Excel Programming 6 February 28th 04 05:35 PM
Loops PaulSinki Excel Programming 3 December 10th 03 05:01 PM


All times are GMT +1. The time now is 03:25 AM.

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

About Us

"It's about Microsoft Excel"