Save worksheet as new workbook (Was saving as PDF)

picklefactory

Well-known Member
Joined
Jan 28, 2005
Messages
506
Office Version
  1. 365
Platform
  1. Windows
Hi folks
Hope this is a very quick easy one.
I have a bit of code that saves a single work sheet as a pdf using the print header as the file name (Which is just today's date). I now need to be doing the same thing but saving as .xlsx rather than pdf, is that a simple change?
Thanks

VBA Code:
Sub AddHeader_CurrentSheetOnly()

'Add P1 from active sheet to active sheet's header
    
    Sheets("PAYROLL TO SEND").Select
    
    With ActiveSheet.PageSetup
        .LeftHeader = Format(Range("P1"), "dd/mm/yyyy")
    End With


' Save PDF copy of 'Payroll to Send' sheet
    
    Dim Path As String
    Dim SaveAsStr As String
    
    Path = Worksheets("PAYROLL TO SEND").Range("P1").Text
    SaveAsStr = "M:\COMPANY SHARED\wages 2\TIMESHEETS HISTORY\" & Path

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
        Filename:=SaveAsStr & ".pdf", _
        OpenAfterPublish:=True

End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi,

instead of
VBA Code:
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
        Filename:=SaveAsStr & ".pdf", _
        OpenAfterPublish:=True
try
VBA Code:
    ActiveSheet.Copy
    ActiveWorkbook.SaveAs Filename:=SaveAsStr & ".xlsx", FileFormat:=51
    ActiveWorkbook.Close False
Ciao,
Holger
 
Upvote 0
Solution

Forum statistics

Threads
1,214,515
Messages
6,119,970
Members
448,933
Latest member
Bluedbw

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