Macro help for clearing contents

Skumby

New Member
Joined
Aug 22, 2012
Messages
36
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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
.
What issue are you having with the line : Range("C10:I23").ClearContents ?

It works here.
 
Upvote 0
.
Well, try this : ActiveSheet.Range("C10:I23").ClearContents
 
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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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