+ Reply to Thread
Results 1 to 6 of 6

VBA to repeat macro x times

  1. #1
    Registered User
    Join Date
    02-01-2012
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2010
    Posts
    97

    VBA to repeat macro x times

    Hi Everyone,

    I have a macro as below

    Please Login or Register  to view this content.
    Its basically looking for "Task 1" and then inserts a line underneath, copies the line from above and adds a day to start and finish.

    I want to be able to repeat this 21 times, so that I end up with 21 "Task 1"s with a start date over 21 days

    I have tried a couple of loops but I cant get this to work.

    Does anyone have any ideas?

    Thanks
    Alex

  2. #2
    Registered User
    Join Date
    02-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    69

    Re: VBA to repeat macro x times

    Try this

    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA to repeat macro x times

    Maybe:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    02-01-2012
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: VBA to repeat macro x times

    thanks for the super quick responses!

    ihmha - Im trying this out at the minute so will let you know
    JOHN H - I get an error with this - Its a compile error (Next withoutFor)

    Ill try to build on these.

    Thanks again
    Alex

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA to repeat macro x times

    Note code in Post#3 was edited. Current version should not produce an error.

  6. #6
    Registered User
    Join Date
    02-01-2012
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: VBA to repeat macro x times

    Apologies for the delay in getting back to you both, both of these work a treat.

    Ive actually gone with ihmha's suggestion as it seems to fit my requirements better.

    Thank you both so much for your help
    Alex

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 03-08-2014, 08:01 AM
  2. [SOLVED] Macro - Repeat macro a specific number of times
    By uvinduds in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-25-2013, 02:42 PM
  3. Need macro help with transposing columns to rows and repeat a row value multiple times
    By InnovativeAJ in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-11-2012, 11:53 AM
  4. How to repeat a macro x number of times based on a value in a cell
    By gypsyhotelier in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-19-2011, 05:11 PM
  5. How to repeat a macro many times
    By cbo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-07-2010, 05:41 PM

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