+ Reply to Thread
Results 1 to 5 of 5

Running macro specific # of times

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-07-2012
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    156

    Running macro specific # of times

    Please........can someone advise code to make a macro run a specific number of times?

    Much appreciated......thanks

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Running macro specific # of times

    The Skipper,

    Something like this should work:
    Sub tgr()
        
        Dim i As Long
        
        For i = 1 To 10 'Replace 10 with your specific number
            Call MacroName
        Next i
        
    End Sub
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Contributor
    Join Date
    02-07-2012
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    156

    Re: Running macro specific # of times

    Thanks.....I'll give it a try.

  4. #4
    Forum Contributor
    Join Date
    02-07-2012
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    156

    Re: Running macro specific # of times

    Should I put your code in the macro I want repeated?

  5. #5
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Running macro specific # of times

    The code is designed to run as its own macro. You would replace MacroName with the name of the macro you want to have repeated. If you want the repeat code to be a part of your existing macro:
    Sub MacroName()
        
        Dim i As Long
        'Here is your existing macro's variable declarations
        
        For i = 1 To 10
            
            ''''''''''''''''''''''''''''
            '                          '
            '   Your macro code here   '
            '                          '
            ''''''''''''''''''''''''''''
            
        Next i
        
    End Sub

+ 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