wrt1mea
asked on
Updating an Excel Macro to include PDF
I am wanting to update the following macro to include saving it as a PDF before clearing the contents
Ideally, I would like the pdf to not open on save and save to the following file path:
C:\Users\admin\Desktop\tem p\INVOICES \PDF
Ideally, I would like the pdf to not open on save and save to the following file path:
C:\Users\admin\Desktop\tem
Sub SvMe()
'Saves filename as value of A1 plus the current date
Dim newFile As String, fName As String
' Don't use "/" in date, invalid syntax
fName = Range("D12").Value
'Change the date format to whatever you'd like, but make sure it's in quotes
newFile = fName & " " & Format$(Date, "mm-dd-yyyy")
' Change directory to suit your PC, including USER NAME
ChDir _
"C:\Users\admin\Desktop\temp\INVOICES"
ActiveWorkbook.SaveAs filename:=newFile
ClearUnlockedCells
End Sub
Sub ClearUnlockedCells()
Dim cel As Range, rg As Range
Application.ScreenUpdating = False
With Worksheets("INVOICE")
Set rg = .Range("B1:J50")
For Each cel In rg.Cells
If (cel.Locked = False) And (cel.Value <> "") Then cel.MergeArea.ClearContents
Next
End With
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Bill!
Works perfectly!!!!
Works perfectly!!!!
Welcome.
»bp
»bp
ASKER
Thanks....I will try on the sheet this evening when I get home from the office. Keep you posted.