View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Range existence check

I am not sure about the validity of your statement that it doesn't work, but
if you want to be more verbose:

Dim rng as Range
Set rng = Nothing
On error Resume Next
set rng = Range("D_Cards")
On error goto 0
if not rng is nothing then
rng.Delete
end if

--
Regards,
Tom Ogilvy

"DoctorG" wrote:

I need to delete a range and re-create it later in my code. I tried the
following but it doesn't work if the range does not exist:

On Error Resume Next
Range("D_CARDS").Delete

How can I check for the existence of a range and, in case it does exist,
delete it, otherwise continue with my code?