PC Review


Reply
Thread Tools Rate Thread

Automating via VBA - Delete "Corrupt" Excel Names

 
 
samadams_2006@yahoo.ca
Guest
Posts: n/a
 
      23rd Oct 2007

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 With Quote
 
 
 
 
Tim Zych
Guest
Posts: n/a
 
      23rd Oct 2007
'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


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete emty file names from "recent documents" Excel Touble in Excel Microsoft Excel Misc 2 22nd Mar 2010 08:10 PM
Field Names: "LongName", "ShortName", "Code", "Description","Comments" PeteCresswell Microsoft Access 2 25th Feb 2009 11:41 PM
"Excel found unreadable content..." "cannot be opened... because itis corrupt" chiefdn@gmail.com Microsoft Excel Crashes 1 2nd Mar 2008 06:19 AM
How do I delete names in "Select Names" list in Ouotlook? =?Utf-8?B?TGlzYVNlcmVuZQ==?= Microsoft Outlook Discussion 7 9th Oct 2007 04:25 AM
Understanding: "BUG: VB Hangs While Automating Excel Using OLE Control" Don Wiss Microsoft Excel Programming 1 5th May 2006 03:28 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:42 PM.