+ Reply to Thread
Results 1 to 4 of 4

How to end loop after two loops?

  1. #1
    Kryer
    Guest

    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. #2
    Norman Jones
    Guest

    Re: 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" <Kryer@discussions.microsoft.com> wrote in message
    news:640FCE6F-9AE7-441B-8AB3-D753D1DBF42E@microsoft.com...
    >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. #3
    Kryer
    Guest

    Re: 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" <Kryer@discussions.microsoft.com> wrote in message
    > news:640FCE6F-9AE7-441B-8AB3-D753D1DBF42E@microsoft.com...
    > >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. #4
    Registered User
    Join Date
    02-05-2005
    Posts
    57
    I use this code for loops when I have up to 4 policy numbers in work that I want to get data for

    Please Login or Register  to view this content.
    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 helps

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1