VBA: Saving A Report With A Standardized Name

You can dictate the naming convention of a file and have a macro save it automatically

  • It can be saved in a specific location
  • It can be date stamped
  • It can be saved in a specific format

There are 2 examples below

  1. PDF based on pivot table filter
  2. Save workbook in a specified location as xlsx and date stamp it

PDF Based On Pivot Table Filter

  • This will save the active worksheet in a specified location as a PDF.
  • Please note: cell C3 is the pivot table filter
Sub SaveAsPdf()

Dim Val As String
Val = ActiveSheet.Range("C3").Value
ActiveSheet.Name = Val

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
  Filename:="C:\Users\rossautomatedsolutions\Desktop\" & Val & ".pdf", _
  Quality:=xlQualityStandard, IncludeDocProperties:=True, _
  IgnorePrintAreas:=False, OpenAfterPublish:=False
  
End Sub

Save Workbook In Specified Location As
xlsx With Date Stamp

Sub SaveAsExcel()
ActiveWorkbook.CheckCompatibility = False
ActiveWorkbook.SaveAs Filename:= _
  "FULL FILE PATH & NAME" & Format(Date, "mm.dd.yyyy") & ".xlsx" _
  , FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
  ReadOnlyRecommended:=False, CreateBackup:=False
End Sub

Sharing

Related Articles

  • All Post
  • Articles
  • Blog Post
  • General Business Automation
  • Portfolio
  • Stock Market & Finance