Testing For a RangeName

J

JCS

Hello Everyone,

I'm not very good at VBA, hiowever, I do have to occaisionally use it. Is
there a way to programatically test for a range name and then delete it if
it exists? Many thank in advance!

John
 
D

Dave Peterson

If you know you want to delete the name, just delete it and ignore any error.

on error resume next
activeworkbook.names("somenamehere").delete
 
M

Mike H

try this

Sub sonic()
Dim RngTest As Range
Set RngTest = Range("Myrange")
On Error GoTo 0
If RngTest Is Nothing Then
MsgBox "Its not there"
Else
RngTest.Delete
End If
End Sub

Mike
 
Top