![]() |
How to end loop after two loops?
I am wanting to create a simple code that will do a loop but will only loop
through the code say 3 times. So example is I start out at the top of column A. I want to do something with: Selection.end(xldown).select in a loop but only have it do this operation 3 times then exit the sub. Any help? |
How to end loop after two loops?
Hi Kryer,
Try using a counter in your code, e.g.: '============ Sub TesterX() Dim i As Long For i = 1 To 3 Selection.End(xlDown).Select Next i End Sub '<<============ --- Regards, Norman "Kryer" wrote in message ... I am wanting to create a simple code that will do a loop but will only loop through the code say 3 times. So example is I start out at the top of column A. I want to do something with: Selection.end(xldown).select in a loop but only have it do this operation 3 times then exit the sub. Any help? |
How to end loop after two loops?
Thanks very much...
now the question i have for you "Norman Jones" wrote: Hi Kryer, Try using a counter in your code, e.g.: '============ Sub TesterX() Dim i As Long For i = 1 To 3 Selection.End(xlDown).Select Next i End Sub '<<============ --- Regards, Norman "Kryer" wrote in message ... I am wanting to create a simple code that will do a loop but will only loop through the code say 3 times. So example is I start out at the top of column A. I want to do something with: Selection.end(xldown).select in a loop but only have it do this operation 3 times then exit the sub. Any help? |
How to end loop after two loops?
I use this code for loops when I have up to 4 policy numbers in wor that I want to get data for Code ------------------- pol1 = range("A1") pol2 = range("A2") pol3 = range("A3") pol4 = range("A4") polarray = array(pol1, Pol2, Pol3, Pol4) Dim iPol as Integer For iPol = 0 to 3 PolNo = Polarray(iPol) '(your code to perform actions/get results) Next iPo ------------------- Basically, if pol 2, 3 & 4 are blank it will only run once and so on. there are other ways also depending on what you are trying to do, another is to start your code with X = X + 1 and at the end say if X 3 then end or else go back to start. hope this help -- rocket061 ----------------------------------------------------------------------- rocket0612's Profile: http://www.excelforum.com/member.php...fo&userid=1949 View this thread: http://www.excelforum.com/showthread.php?threadid=48745 |
All times are GMT +1. The time now is 02:43 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com