Consulting

Results 1 to 4 of 4

Thread: Solved: How do I run a macro a set number of times

  1. #1
    VBAX Regular markyc's Avatar
    Joined
    Sep 2005
    Posts
    27
    Location

    Question Solved: How do I run a macro a set number of times

    I have two sheets

    Sheet 1 has a list of risk numbers in column A, this list can be upto 2000 records long

    Sheet 2 is a report that needs to contain the risk number at the top of the report.

    I have created a macro that copies first risk number, pastes into top of report, prints report, goes back to sheet 1 and selects next risk number.

    I want to be able to tell macro only to do this loop 10 times, to ease data sent to network printer

    Please can you advise

  2. #2
    Administrator
    Chat VP
    VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Put the code into a loop e.g.
    [VBA]Option Explicit

    Sub DoTenTimes()

    Dim N As Long

    For N = 1 To 10

    'put all your code here

    Next N

    End Sub[/VBA]
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  3. #3
    VBAX Regular markyc's Avatar
    Joined
    Sep 2005
    Posts
    27
    Location
    Thanks for your quick reply

    This has worked

  4. #4
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Not a prob
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

Posting Permissions

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