Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default 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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default 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?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

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???? harry buggy Excel Worksheet Functions 2 August 14th 07 06:33 PM
For next loops Kate Excel Discussion (Misc queries) 5 May 22nd 06 01:11 PM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
Loops etc. Jonathan Vickers Excel Programming 6 February 28th 04 05:35 PM


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