I'm new here and also in VBA. I'm trying to figure out to export active sheet to new workbook (just values) and save it as specific name where part of the name has to be month converted to two digits format. To be more specific there is a month name in "D4". I need to use this month in the name of the new workbook but converted to two digits format.
With ActiveSheet
ActiveSheet.Range("A1:M40").Copy
Set NewBook = Workbooks.Add
With NewBook
NewBook.Worksheets("Sheet1").Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Dim LMonth As Integer
NewBook.SaveAs Filename:=ThisWorkbook.Path & "\" & Range("D4") & "_" & Range("I2") & "_" & " FLA"
End With
End With
Here is the full code which prints out the sheet as pdf and then exports the sheet to new workbook:
Private Sub Print_PDF_Click()
With ActiveSheet
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ThisWorkbook.Path & "\" & ActiveSheet.Name & " " & Range("I2") & " FLA" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
With ActiveSheet
ActiveSheet.Range("A1:M40").Copy
Set NewBook = Workbooks.Add
With NewBook
NewBook.Worksheets("Sheet1").Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Dim LMonth As Integer
NewBook.SaveAs Filename:=ThisWorkbook.Path & "\" & Format(Range("D4"),"mm") & "_" & Range("I2") & "_" & " FLA"
End With
End With
MsgBox "PDF successfully created!"
End With
End Sub
Please help!