Macro help for clearing contents

Skumby

New Member
Joined
Aug 22, 2012
Messages
34
I have spreadsheets that we print to PDF via macro. The boss wants me to add a step that once the spreadsheet is printed to PDF it clears the contents.

I have created this but the ClearContents step needs debugging. Please help :)

Sub POSaveAs()

'
Dim strFilename As String
Const strPath As String = "F:\Timesheets\Approved Timesheets"


strFilename = Value & "EMP" & " - " & Range("J5") & " - " & Range("J2") & " - " & Replace(Range("A23").Value, "/", "-")

ChDrive "F:\Timesheets\Approved Timesheets"
ChDir strPath

Application.DisplayAlerts = False

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFilename, IgnorePrintAreas:=False, OpenAfterPublish:=True

Application.DisplayAlerts = True

Range("C10:I23").ClearContents

End Sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
.
What issue are you having with the line : Range("C10:I23").ClearContents ?

It works here.
 
Upvote 0
What is the name of the worksheet you are attempting to clear the contents ?
 
Upvote 0
I'm such a nitwit, it was due to the protection. in a row in the middle of the cell selection. Its working now, thank you :)
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,199
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top