Modify to only work with nominated range instead of entire sheet

C

Corey

~~~~~~~~~~~~~~~~~~~~~~~
Dim c As Range
For Each c In Sheets("REPORT").UsedRange
If c.Locked = False Then c.Value = ""
Next c
End If
~~~~~~~~~~~~~~~~~~~~~~
The above code clears all cells in a sheet(REPORT) that are Not Locked.
However it seem to take a while to process.

How could i add a line to ONLY refer to a range of ( A1:AC960) instead of
the entire sheet ?
 
J

Jim Cone

Note: the "UsedRange" is not the entire sheet.
'--
Sub SetThemFree()
On Error GoTo ViolatedParole
Dim c As Range
Application.ScreenUpdating = False
Application.Calculation = xlManual
For Each c In Sheets("REPORT").Range("A1:AC960").Cells
If c.Locked = False Then c.Value = vbNullString
Next 'c
ViolatedParole:
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
End Sub
--
Jim Cone
Portland, Oregon USA


"Corey"
wrote in message
~~~~~~~~~~~~~~~~~~~~~~~
Dim c As Range
For Each c In Sheets("REPORT").UsedRange
If c.Locked = False Then c.Value = ""
Next c
End If
~~~~~~~~~~~~~~~~~~~~~~
The above code clears all cells in a sheet(REPORT) that are Not Locked.
However it seem to take a while to process.

How could i add a line to ONLY refer to a range of ( A1:AC960) instead of
the entire sheet ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top