Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
loops???? | Excel Worksheet Functions | |||
For next loops | Excel Discussion (Misc queries) | |||
Advancing outer Loop Based on criteria of inner loop | Excel Programming | |||
Problem adding charts using Do-Loop Until loop | Excel Programming | |||
Loops etc. | Excel Programming |