VBA Code to save worksheet to new workbook

Wafee

Board Regular
Joined
May 27, 2020
Messages
104
Office Version
  1. 2013
Platform
  1. Windows
Hi,

There are lot of similar questions but somehow its not working out for me.

I want to save the sheet (Source) from the active workbook as a new workbook where sheet name remains same and work book name must be "Source dd/mm/yy".xlsx.

This workbook needs to be saved in the same path as active work book whihc is "C:\Reports\Source". thank you in advance.
 

Some videos you may like

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
48,402
Office Version
  1. 365
Platform
  1. Windows
How about
VBA Code:
Sub Wafee()
   Dim Pth As String
   
   Pth = ActiveWorkbook.Path
   Sheets("Source").Copy
   ActiveWorkbook.SaveAs Pth & "\Source " & Format(Date, "dd-mm-yy") & ".xlsx", 51
End Sub
 
Solution

Wafee

Board Regular
Joined
May 27, 2020
Messages
104
Office Version
  1. 2013
Platform
  1. Windows
How about
VBA Code:
Sub Wafee()
   Dim Pth As String
   
   Pth = ActiveWorkbook.Path
   Sheets("Source").Copy
   ActiveWorkbook.SaveAs Pth & "\Source " & Format(Date, "dd-mm-yy") & ".xlsx", 51
End Sub
Thanks mate. That worked.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
48,402
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,114,471
Messages
5,548,218
Members
410,824
Latest member
Bobmn4
Top