Hi,
I use a macro to create/save a PDF file to my computer and it works great. Is there a way to change this code or another code that will do the same thing except create/save a new Excel workbook with the same data? I have a large workbook and sometimes I need to take specific data from it and enter it into a new workbook sheet. As of now, I have to create the new workbook, copy the data and then paste it to the new workbook. It would be great if I could just click a macro button that then creates a new workbook with the specific data in it... just like the macro does with a PDF file. Is this possible?
Here is the PDF macro code I use...
Private Sub CreatePDF()
Dim wSheet As Worksheet
Dim vFile As Variant
Dim sFile As String
Set wSheet = ActiveSheet
sFile = Replac(Replac(wSheet.Name, " ", ""), ".", "_") _
& "_" _
& Format(Now(), "yyyymmdd\_hhmm") _
& ".pdf"
sFile = ThisWorkbook.Path & "\" & sFile
vFile = Application.GetSaveAsFilename _
(InitialFileName:=sFile, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and File Name to save")
With ActiveSheet.PageSetup
.Orientation = xlLandscape
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
End With
If vFile <> "False" Then
wSheet.Range("H1:O" & Range("H" & Rows.Count).End(xlUp).Row).ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=vFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
aPDFcreated.show
End If
End Sub
Bookmarks