![]() |
Testing For a RangeName
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 |
Testing For a RangeName
If you know you want to delete the name, just delete it and ignore any error.
on error resume next activeworkbook.names("somenamehere").delete on error goto 0 JCS wrote: 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 -- Dave Peterson |
Testing For a RangeName
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 "JCS" wrote: 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 |
Testing For a RangeName
Dave/Mike
Thank you very much. I tried both methods and both work great!!!! John "JCS" wrote: 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 |
All times are GMT +1. The time now is 10:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com