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



Hi there,

Is there an easy way of deleting all defined names in a tab? (other than
selecting Insert, Names, Define, selecting them individually and then
delete)

Thanks

D

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Clearing Names..

Public Sub DeleteNames(SheetName As String)
Dim ThisName As Name

For Each ThisName In ThisWorkbook.Names
On Error GoTo Skip
If ThisName.RefersTo Like "=" & SheetName & "!*" Then ThisName.Delete
Skip:
Next ThisName

End Sub

"Darin Kramer" wrote:



Hi there,

Is there an easy way of deleting all defined names in a tab? (other than
selecting Insert, Names, Define, selecting them individually and then
delete)

Thanks

D

*** Sent via Developersdex http://www.developersdex.com ***

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Clearing Names..

Do you mean

- all names in this workbook
- only names that refer to a range in this worksheet
- only names local to this worksheet?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"K Dales" wrote in message
...
Public Sub DeleteNames(SheetName As String)
Dim ThisName As Name

For Each ThisName In ThisWorkbook.Names
On Error GoTo Skip
If ThisName.RefersTo Like "=" & SheetName & "!*" Then ThisName.Delete
Skip:
Next ThisName

End Sub

"Darin Kramer" wrote:



Hi there,

Is there an easy way of deleting all defined names in a tab? (other than
selecting Insert, Names, Define, selecting them individually and then
delete)

Thanks

D

*** Sent via Developersdex http://www.developersdex.com ***



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 397
Default Clearing Names..



Thanks - I have pasted it into VBA, but how do I get it to run? (I dont
know the difference between a PUblic Sub and just a normal Sub?) Also
Could I replace Sheetname with the sheet name to which I want all names
to be deleted?

Appreciate your help.

D

*** Sent via Developersdex http://www.developersdex.com ***
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 397
Default Clearing Names..


Hi Bob,

To answer your question, only names local to the worksheet.

Thanks

D


*** Sent via Developersdex http://www.developersdex.com ***


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Clearing Names..

Darin,

KDales' code will only delete names that refer toa range in this worksheet.
So you need

Public Sub DeleteNames(SheetName As String)
Dim ThisName As Name

For Each ThisName In ThisWorkbook.Names
On Error GoTo Skip
If ThisName.Name Like "=" & SheetName & "!*" Then
ThisName.Delete
End If
Skip:
Next ThisName

End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Darin Kramer" wrote in message
...

Hi Bob,

To answer your question, only names local to the worksheet.

Thanks

D


*** Sent via Developersdex http://www.developersdex.com ***



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Clearing Names..

If this is a one time thing, I'd use Jan Karel Pieterse's (with Charles Williams
and Matthew Henson) Name Manager to clean things up.

You can find it at:
NameManager.Zip from http://www.oaltd.co.uk/mvp

It has lots of options--including showing only those names that are worksheet
level names.

Darin Kramer wrote:

Hi there,

Is there an easy way of deleting all defined names in a tab? (other than
selecting Insert, Names, Define, selecting them individually and then
delete)

Thanks

D

*** Sent via Developersdex http://www.developersdex.com ***


--

Dave Peterson
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
Clearing cells without clearing formulas marsjune68 Excel Discussion (Misc queries) 2 April 10th 09 07:39 PM
Clearing #N/A's in one go? Lee Harris Excel Worksheet Functions 5 November 22nd 05 06:52 PM
Clearing #VALUE skateblade Excel Worksheet Functions 3 October 15th 05 10:34 PM
clearing VBA worksheet names Maynard Excel Programming 2 July 8th 04 07:45 PM
Exel VBA - Clearing clipboard, area names Timse Excel Programming 2 June 11th 04 09:35 AM


All times are GMT +1. The time now is 10:18 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"