Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Automating via VBA - Delete "Corrupt" Excel Names


Hello,

I have some corrupt excel names in spreadsheets I'm sent from time to
time. I can get rid of these via the nformation outlined in the
Microsoft article:

http://support.microsoft.com/default...b;en-us;555127

but I would like to "Automate" this. I know that there is a VBA Guru
out there that can help me out. Perhaps you need to use the
FindWindow API? Perhaps there is another way.

Can someone send me some sample code that will automate this deletion
process rather than having to delete every single corrupt name
individually?

Thanks
Sam

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Automating via VBA - Delete "Corrupt" Excel Names

'Deletes bad range names
Sub DeleteBadRangeNames()
Dim nm As Name
For Each nm In ThisWorkbook.Names
If nm.RefersTo Like "*[#]REF*" Then
' View in the immediate window first
debug.print nm.RefersTo
' If satisfied with bad-name list, uncomment
' and run again:
' nm.Delete
End If
Next 'nm
End Sub

I commented out the actual delete action so you can check the bad names
first. If you have a lot, you might want to print them out to a new
workbook, because they won't fit in the immediate pane. Both macros go in
the workbook with the bad range names.

Sub DeleteBadRangeNames2()
Dim nm As Name
Dim wkbWithNames As Workbook, wkbOutput As Workbook
Set wkbWithNames = ThisWorkbook
Set wkbOutput = Workbooks.Add(1)
For Each nm In wkbWithNames.Names
If nm.RefersTo Like "*[#]REF*" Then
' Print out to a new workbook first
With wkbOutput.Worksheets(1).Cells(65000, 1).End(xlUp).Offset(1)
.Value = nm.Name
.Offset(, 1).Value = "'" & nm.RefersTo
End With
' If satisfied with bad-name list, uncomment
' and run again:
' nm.Delete
End If
Next
End Sub


wrote in message
oups.com...

Hello,

I have some corrupt excel names in spreadsheets I'm sent from time to
time. I can get rid of these via the nformation outlined in the
Microsoft article:

http://support.microsoft.com/default...b;en-us;555127

but I would like to "Automate" this. I know that there is a VBA Guru
out there that can help me out. Perhaps you need to use the
FindWindow API? Perhaps there is another way.

Can someone send me some sample code that will automate this deletion
process rather than having to delete every single corrupt name
individually?

Thanks
Sam



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
Delete emty file names from "recent documents" Excel Touble in Excel Excel Discussion (Misc queries) 2 March 22nd 10 08:10 PM
Excel "Move or Copy" and "Delete" sheet functions dsiama Excel Worksheet Functions 1 December 28th 07 01:57 PM
Delete "Unused names" in a batch D0306 Excel Discussion (Misc queries) 2 July 18th 07 04:40 PM
Delete All Names - Even Invalid "#REF" Names Brian B. Excel Programming 1 April 2nd 07 11:22 PM
Understanding: "BUG: VB Hangs While Automating Excel Using OLE Control" Don Wiss Excel Programming 1 May 5th 06 03:28 AM


All times are GMT +1. The time now is 09:46 AM.

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"