Hello how can I create a new folder and save a certain sheet inside it as PDF and name it with a specific cell value. Taking into account that I copy the data several times, each time I must create a new folder in case it does not already exist with the name of cell B5
VBA Code:
Private Sub CommandButton1_Click()
Dim ws As Worksheet
Dim strPath As String
Dim myFile As Variant
Dim strFile As String
On Error GoTo errHandler
Set ws = Sheet4
'enter name and select folder for file
' start in current workbook folder
strFile = ThisWorkbook.Path & "\" & strFile
myFile = Application.GetSaveAsFilename _
(InitialFileName:=strFile, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and FileName to save")
If myFile <> "False" Then
ws.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=myFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
MsgBox "done"
End If
exitHandler:
Exit Sub
errHandler:
MsgBox "Error"
Resume exitHandler
End Sub