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

I posted a few days ago and got the following cod to remove any 'MISSING'
References form my '97 file after it has been worked on in a newer version:

Sub removebrokenreferences()
Dim Counter As Integer
With ThisWorkbook.VBProject.References
For Counter = 1 To .Count
If .Item(Counter).IsBroken Then
.Remove .Item(Counter)
End If
Next
End With
End Sub

I can't seem to get it to work properly. In my Reference box I have 7
ticked, the last 2 are 'MISSING' and are obviously the ones I want to
remove. When I run the macro it gets rid of the first but not the second,
is it something to do with the .Count bit?

It counts 7 so checks 7 References, but after the 6th is checked and removed
because it is broken there isn't a 7th to check so instead looks at an
unticked reference which causes an error. The second 'MISSING' becomes the
6th in the box so is not checked.

Is my theory correct?

If so, is there a way around it?

Thanks in advance.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Broken References

Sub removebrokenreferences()
Dim Counter As Integer
With ThisWorkbook.VBProject.References
For Counter = .Count To 1 Step -1
If .Item(Counter).IsBroken Then
.Remove .Item(Counter)
End If
Next
End With
End Sub

--
Regards,
Tom Ogilvy


"Gareth" wrote in message
...
I posted a few days ago and got the following cod to remove any 'MISSING'
References form my '97 file after it has been worked on in a newer

version:

Sub removebrokenreferences()
Dim Counter As Integer
With ThisWorkbook.VBProject.References
For Counter = 1 To .Count
If .Item(Counter).IsBroken Then
.Remove .Item(Counter)
End If
Next
End With
End Sub

I can't seem to get it to work properly. In my Reference box I have 7
ticked, the last 2 are 'MISSING' and are obviously the ones I want to
remove. When I run the macro it gets rid of the first but not the second,
is it something to do with the .Count bit?

It counts 7 so checks 7 References, but after the 6th is checked and

removed
because it is broken there isn't a 7th to check so instead looks at an
unticked reference which causes an error. The second 'MISSING' becomes

the
6th in the box so is not checked.

Is my theory correct?

If so, is there a way around it?

Thanks in advance.





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
How to convert all 3d references to normal references in a workboo Dima Excel Discussion (Misc queries) 6 August 8th 08 12:38 PM
How to convert all 3d references to normal references in a workboo Dima Excel Worksheet Functions 6 August 8th 08 12:38 PM
Help with converting a block of cells with Absolute and mixed references to relative references Vulcan Excel Worksheet Functions 3 December 13th 07 11:43 PM
How to rename references from range names to cell references Abbas Excel Discussion (Misc queries) 1 May 24th 06 06:18 PM
Named references broken on copied worksheet DNicolay Excel Discussion (Misc queries) 0 December 12th 05 04:49 PM


All times are GMT +1. The time now is 12:26 PM.

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"