Hi experts,
i wonder if someone can help me on this please :
I have 2 command buttons in my spreadsheet
1. Create PDF
2. Clear Contents
What I want that clear contents macro should only work if the create PDF macro has run fully othrwise message box come up to say Create PDF first.
Please can someone guide me.
thank you
i wonder if someone can help me on this please :
I have 2 command buttons in my spreadsheet
1. Create PDF
2. Clear Contents
What I want that clear contents macro should only work if the create PDF macro has run fully othrwise message box come up to say Create PDF first.
Please can someone guide me.
thank you
VBA Code:
Sub CreatePDF_Click()
pdfName = Sheets("Sheet1").Range("C1").Value
ChDir "C:\User"
fileSaveName = Application.GetSaveAsFilename(pdfName, _
fileFilter:="PDF Files (*.pdf), *.pdf")
If fileSaveName <> False Then
Sheets(Array("Sheet1", "2", "3")).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=fileSaveName, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
Sheets("Sheet1").Select
Exit Sub
End If
End Sub
Code:
Sub Newday()
Sheets("Sheet1").Select
With ActiveSheet
.Unprotect
With Range("A1:O40 ")
.Locked = False
.ClearContents
End With
.Protect
End With