Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Control Deletion of Range Names


Cheers all!

I want to perform the following simple task:

Check all the Range Names in a certain Workbook, and delete some o
them according to certain criteria (e.g. delete a Range Name if it
first 3 characters are XXX).

I'm using the following Sub, which doesn't work:

Sub DELETE_SOME_RANGE_NAMES()

Dim nm As Name

For Each nm In ActiveWorkbook.Names
If Left(nm, 3) = "XXX" Then
nm.Delete
End If
Next

End Sub

Using a Msgbox to check what values the Object Variable nm is gettin
(MsgBox = "nm = " & nm), I noted that its value is:
= << Sheet or Location ! << Address

Obviously, I would rather have Variable nm as the actual name o
whatever Range in order to control a string (the actual name) rathe
than a location & address...

Is there any way around this?

Thank you very much for your time,

Ale

--
Alex Hatzisava
-----------------------------------------------------------------------
Alex Hatzisavas's Profile: http://www.excelforum.com/member.php...fo&userid=1455
View this thread: http://www.excelforum.com/showthread.php?threadid=26229

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Control Deletion of Range Names

Hi Alex,

Try:

Sub DELETE_SOME_RANGE_NAMES()
Dim nm As Name
Dim pos as Long
Dim sStr As String
For Each nm In ActiveWorkbook.Names
pos = InStr(nm.Name, "!") + 1
sStr = Mid(nm.Name, pos, 255)
If Left(sStr, 3) = "XXX" Then
nm.Delete
End If
Next
End Sub


---
Regards,
Norman



"Alex Hatzisavas" wrote in
message ...

Cheers all!

I want to perform the following simple task:

Check all the Range Names in a certain Workbook, and delete some of
them according to certain criteria (e.g. delete a Range Name if its
first 3 characters are XXX).

I'm using the following Sub, which doesn't work:

Sub DELETE_SOME_RANGE_NAMES()

Dim nm As Name

For Each nm In ActiveWorkbook.Names
If Left(nm, 3) = "XXX" Then
nm.Delete
End If
Next

End Sub

Using a Msgbox to check what values the Object Variable nm is getting
(MsgBox = "nm = " & nm), I noted that its value is:
= << Sheet or Location ! << Address

Obviously, I would rather have Variable nm as the actual name of
whatever Range in order to control a string (the actual name) rather
than a location & address...

Is there any way around this?

Thank you very much for your time,

Alex


--
Alex Hatzisavas
------------------------------------------------------------------------
Alex Hatzisavas's Profile:
http://www.excelforum.com/member.php...o&userid=14559
View this thread: http://www.excelforum.com/showthread...hreadid=262297



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
converting email address names in a range of cells to real names John Excel Worksheet Functions 1 May 19th 10 03:44 PM
COPYING FORMULA CONTAINING NAMES/RELATIVE RANGE NAMES Bricol Excel Discussion (Misc queries) 0 July 8th 08 03:54 PM
Mass deletion of block names danhattan Excel Discussion (Misc queries) 2 February 3rd 07 01:44 PM
Range deletion gavmer[_46_] Excel Programming 1 July 2nd 04 01:09 AM
Variable Control Names Garry Jones Excel Programming 4 October 3rd 03 10:45 PM


All times are GMT +1. The time now is 11:45 PM.

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

About Us

"It's about Microsoft Excel"