Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
JCS JCS is offline
external usenet poster
 
Posts: 93
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.misc
JCS JCS is offline
external usenet poster
 
Posts: 93
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
TESTING Eamon Excel Worksheet Functions 0 July 11th 08 04:41 PM
Confused with RangeName CellREfs Jim May Excel Discussion (Misc queries) 1 October 23rd 06 12:11 AM
ActiveWorkbook.Protect password:=range("rangename") does not work WimR Excel Discussion (Misc queries) 1 June 26th 05 09:47 AM
Testing Tony Excel Discussion (Misc queries) 0 June 4th 05 06:39 PM
Concatenate RangeName for INDEX? CLR Excel Worksheet Functions 5 November 30th 04 08:47 PM


All times are GMT +1. The time now is 05:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"