+ Reply to Thread
Results 1 to 3 of 3

For loop to save file multiple times with different names each time

  1. #1
    Registered User
    Join Date
    12-06-2014
    Location
    Arizona
    MS-Off Ver
    2011
    Posts
    20

    For loop to save file multiple times with different names each time

    I am trying to write a macro that will save the same document 31 times, renaming it each time to match each day of the month. The prompts for the macro work, and I can see the notice in the lower right hand corner of the excel window stating that iterative copies of the document are being saved, but the folder remains empty after the process is complete. I am executing the macro inside the folder that I want the copies to be saved to, so I have not specified a file path in the macro. If I execute the code a second time, I get a prompt asking me if I would like to overwrite the previous copy of the document (even though none exists in the active folder). Can anyone tell me what is wrong with my code?


    Sub transmittals()
    myMonth = Application.InputBox(Prompt:="Input month as a number", Type:=1)
    myYear = Application.InputBox(Prompt:="Input year as a two-digit number", Type:=1)
    For i = 1 To 31
    ActiveWorkbook.SaveAs (myMonth & "." & i & "." & myYear & ".xlsm")
    'Alternatively I have also tried the line of code below:
    'ActiveWorkbook.SaveAs Filename:=myMonth & "." i & "." & myYear, FileFormat:= 53
    Next
    End Sub

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,523

    Re: For loop to save file multiple times with different names each time

    Have you done a search for these workbooks?
    They're probably in the Root Directory

    Please Login or Register  to view this content.
    Last edited by jolivanes; 12-06-2014 at 01:38 AM.

  3. #3
    Registered User
    Join Date
    12-06-2014
    Location
    Arizona
    MS-Off Ver
    2011
    Posts
    20

    Re: For loop to save file multiple times with different names each time

    That worked, thanks so much!

+ 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. [SOLVED] save as with variable name, loop 10,000 times
    By seantabler in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-01-2014, 01:34 PM
  2. Loop to execute SAVE code as defined number of times
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-10-2013, 08:15 AM
  3. MACRO - Paste value and then save file multiple times ---- please help
    By aetedford in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-10-2013, 08:53 PM
  4. Replies: 3
    Last Post: 12-16-2012, 03:22 PM
  5. can I save a file of multiple names to replace using excell 03
    By Greg is working hard. in forum Excel General
    Replies: 2
    Last Post: 07-18-2006, 08:45 AM

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