+ Reply to Thread
Results 1 to 3 of 3

Thread: Run Macro Many Times Automatically

  1. #1
    Registered User
    Join Date
    08-21-2010
    Location
    Omaha, NE
    MS-Off Ver
    Excel 2003
    Posts
    40

    Run Macro Many Times Automatically

    Have simple copy-paste macro, but I'd like to be able to run it exactly 5,000 times without holding down Ctrl+r for 10 minutes. Would someone please show me how to modify this code so that another macro will run the 'DTC_copy_paste Macro' 5,000 times? Thanks!

    Sub DTC_copy_paste()
    '
    ' DTC_copy_paste Macro
    '
    ' Keyboard Shortcut: Ctrl+r
    '
        ActiveCell.FormulaR1C1 = "=R[3]C[120]"
        Range("A1").Select
        Selection.Copy
        Range("A2").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
    End Sub
    Last edited by Greg777; 01-22-2012 at 03:20 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    12-14-2009
    Location
    San Francisco, CA
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    986

    Re: Run Macro Many Times Automatically

    Sub DTC_copy_paste()
    '
    ' DTC_copy_paste Macro
    '
    ' Keyboard Shortcut: Ctrl+r
    '
    Dim HowManyTimes As Long: HowManyTimes = 500
    Dim i As Long
    
        For i = 1 To HowManyTimes
        ActiveCell.FormulaR1C1 = "=R[3]C[120]"
        Range("A1").Select
        Selection.Copy
        Range("A2").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Next i
    End Sub
    To thank someone who has helped you, click on the star icon below their name.

    I hate reading

    Portfolio

    I need a job.
    I am young and incompetent

  3. #3
    Registered User
    Join Date
    08-21-2010
    Location
    Omaha, NE
    MS-Off Ver
    Excel 2003
    Posts
    40

    Re: Run Macro Many Times Automatically

    Works- thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0