How to create multiple files?

manbearpig

New Member
Joined
Sep 28, 2010
Messages
2
Dear All, I have a following dilemma:

I need to create multiple files from a single file while automatically changing one cell.

the file is called "Property1 20100931"

Sheet1!J3 contains date let's say 9/31/2010

I need to create 30 files with decreasing date i.e.

changing DATE in Sheet1!J3 to 9/30/2010 and changing FILE NAME to "Property1 20100930" ..... all the way to 9/1/2010

All of these files I want to save in a single folder.


I would greatly appreciate any thoughts!

Thank you!
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi,

Try this macro

Code:
Sub MakeABunchOfNearDuplicateFiles()
    Dim Wb             As Workbook
    Dim MyDate         As Date
    Dim MyName         As String
    Dim MyNewName      As String
    Dim dayCounter     As Long
    Set Wb = ActiveWorkbook
    MyName = Wb.Name
    MyDate = Wb.Worksheets("Sheet1").Cells(3, 10)
    dayCounter = Day(MyDate)
    Do
        dayCounter = dayCounter - 1
        If dayCounter = 0 Then Exit Do
        Wb.Worksheets("Sheet1").Cells(3, 10) = Wb.Worksheets("Sheet1").Cells(3, 10) - 1
        Wb.SaveAs ("C:\The Save Folder\" & Left(MyName, 10) & Year(MyDate) _
                   & Right("0" & Month(MyDate), 2) & Right("0" & dayCounter, 2))
    Loop
 
End Sub

you'll need to change the "C:\The Save Folder\" to the correct path.
The macro also doesn't make 30 new books: it makes a book for every day down to the first day of the month.
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,924
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top