+ Reply to Thread
Results 1 to 3 of 3

VBA loop to copy a worksheet a number of times, assign name each time based on loop number

Hybrid View

  1. #1
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,715

    Re: VBA loop to copy a worksheet a number of times, assign name each time based on loop nu

    hi
    looks like you're almost there with your macro

    try this variation (I've set it to copy file "Near leader output sheet 1", not file 15)

    Sub CopyWorksheetXTimes()
     Dim x As Integer
    
     x = InputBox("Enter number of times to copy Near leader output sheet 1")
     For numtimes = 1 To x
     ActiveWorkbook.Sheets("Near leader output sheet 1").Copy _
     after:=ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)
     ActiveSheet.Name = "Near leader output sheet " & numtimes + 1
     Next
    
     End Sub
    can I ask you to edit your post and put code tabs around the macro code - otherwise a moderator will ping you!

  2. #2
    Registered User
    Join Date
    11-29-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: VBA loop to copy a worksheet a number of times, assign name each time based on loop nu

    Thanks Nicky, worked perfectly, you're the best!

    Also appreciate the help on the code tagging - didn't realize.

+ 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.6.0 RC 1