Testing For a RangeName

  • Thread starter Thread starter JCS
  • Start date Start date
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
 
If you know you want to delete the name, just delete it and ignore any error.

on error resume next
activeworkbook.names("somenamehere").delete
 
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
 
Dave/Mike

Thank you very much. I tried both methods and both work great!!!!
John
 

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

Back
Top