If you're going to use "On error", why not just:
On Error Resume Next
Selection.SpecialCells(xlCellTypeConstants).ClearC ontents
On Error GoTo 0
===
But depending on what the selection is, I'd use:
On Error Resume Next
intersect(selection,Selection.SpecialCells(xlCellT ypeConstants)).ClearContents
On Error GoTo 0
it'll avoid any problems if a single cell is selected.
Sandy Mann wrote:
Or rather:
On Error Resume Next
If Selection.SpecialCells(xlCellTypeConstants) Is Nothing Then
Exit Sub
Else
Selection.SpecialCells(xlCellTypeConstants).ClearC ontents
End If
On Error GoTo 0
(Got mixed up with JLGWhiz JLGWhiz's code)
--
HTH
Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings
Replace @mailinator.com with @tiscali.co.uk
"access user" wrote in message
...
If Selection.SpecialCells(xlConstants) Is Nothing Then
Exit Sub
Else
Selection.SpecialCells(xlConstants).ClearContents
End If
Basically, if the cells in question (either a selection or a range) are
already cleared then I do not want the sub run, otherwise I want it run.
The
above is not trapping that condition as the last line before End If always
runs and brings up the error 'no cells' - I do not want this error to be
shown, just want the code to terminate in that case.
tia
James
--
Dave Peterson