Automatic saving to multiple destination.

Olyn01

New Member
Joined
Mar 12, 2019
Messages
12
Is it possible to save your workbook to 2 destinations?
When I try to put 2 destination on VB it doesn't work.

Code:
Sub SaveAs()


    Dim FName           As String
    Dim FPath           As String
    Dim NewBook         As Workbook
    
Application.ScreenUpdating = False
    FPath = "C:\Users\ROOM\Desktop\Monitoring\"
    FName = "Monitoring " & Format(Date, "DD-MMM-YYYY") & ".xls"
      
    Set NewBook = Workbooks.Add
    
    ThisWorkbook.Sheets("MasterCopy").Copy Before:=NewBook.Sheets(1)
    
    If Dir(FPath & "\" & FName) <> "" Then
        MsgBox "File" & FPath & "\" & FName & "already exists"
    Else
        NewBook.SaveAs Filename:=FPath & FName
    End If
Application.ScreenUpdating = True


Application.ScreenUpdating = False
Workbooks("Monitoring " & Format(Date, "DD-MMM-YYYY") & ".xls").Close SaveChanges:=True
Application.ScreenUpdating = True
 
Last edited:

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
.
Code:
Option Explicit


Sub sb_Copy_Save_ActiveSheet_As_Workbook()
Dim wb As Workbook
Set wb = Workbooks.Add
ThisWorkbook.Activate
ThisWorkbook.Worksheets("Sheet1").Range("A1:K10").Copy
wb.Worksheets("Sheet1").Range("A1").PasteSpecial (xlPasteValues)


wb.SaveAs "C:\Users\My\desktop\New Folder\" & Range("H1").Value & ".xlsx"   '<---- change save location & name here


wb.SaveAs "C:\Users\My\desktop\Other\" & Range("H1").Value & ".xlsx"   '<---- change save location & name here
End Sub
 
Upvote 0
Continuing with your idea.
put your destination 2 in the red letters
Note: the newbook must be closed until the end, since you have saved the 2 books

Code:
Sub SaveAs()
    Dim fName           As String
    Dim fPath1          As String, fPath2 As String
    Dim NewBook         As Workbook
    
    Application.ScreenUpdating = False
    fPath1 = "C:\Users\ROOM\Desktop\Monitoring\"
    fPath2 = "[COLOR=#ff0000]C:\trabajo\books\[/COLOR]"
    fName = "Monitoring " & Format(Date, "DD-MMM-YYYY") & ".xls"
      
    Set NewBook = Workbooks.Add
    
    ThisWorkbook.Sheets("MasterCopy").Copy Before:=NewBook.Sheets(1)
    
    'save in path1
    If Dir(fPath1 & fName) <> "" Then
        MsgBox "File " & fPath1  & fName & " already exists"
    Else
        NewBook.SaveAs Filename:=fPath1 & fName
    End If
    
    'save in path2
    If Dir(fPath2 & fName) <> "" Then
        MsgBox "File " & fPath2 & fName & " already exists"
    Else
        NewBook.SaveAs Filename:=fPath2 & fName
    End If
    
    NewBook.Close SaveChanges:=False
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
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