Dave Hawley, about your external link macro (take a look)


Posted by Steve W on May 01, 2001 1:06 PM

Dave this macro did all the formulas in the workbook, I thought it was only suppost to do external links.(It still helped out me out a lot) It makes a real good formula report generator. Also I modified it to tell you what sheet the formulas on and what cell.

I have a questine for you, I trying to add this macro to a menubar addin that I developed for tools I use a lot, but it only generates the page "link list" it doesn't write all the formulas and info in the cells.


Thanks for any help you can provide
steve W


Sub ListExternalLinks()

'Written by OzGrid Business Applications
'www.ozgrid.com

'''''''''''''''''''''''''''''''''''''''''''''''''''''
'Creates a Worsheet called "Link List" and lists ALL _
external links in the Workbook.
'''''''''''''''''''''''''''''''''''''''''''''''''''''

Dim sht As Worksheet
Dim LinkCells As Range, Cell As Range
'Add a new sheet to list all external links.
On Error Resume Next
Sheets.Add().Name = "Link List"
Application.DisplayAlerts = False
'If name does NOT = "Link List" then it already exists
If ActiveSheet.Name <> "Link List" Then ActiveSheet.Delete
Application.DisplayAlerts = True
'Clear column A and format as text.
Sheets("Link List").Columns(1).Clear
Sheets("Link List").Columns(2).Clear
Sheets("Link List").Columns(3).Clear
Sheets("Link List").Columns(3).NumberFormat = "@"
'Loop through each worksheet
For Each sht In ThisWorkbook.Worksheets
'Set "LinkCells" to range that has formulas
Set LinkCells = Nothing
Set LinkCells = sht.Cells.SpecialCells(xlCellTypeFormulas)
If Not LinkCells Is Nothing Then
'Loop through each cell in "LinkCells"
For Each Cell In LinkCells
'See if if an external link or not.
If Cell.Formula Like "[*" Then
'It is, so copy the formula to column A of "Link List"
Sheets("Link List").Cells _
(65536, 1).End(xlUp).Offset(1, 0) = sht.Name
Sheets("Link List").Cells _
(65536, 2).End(xlUp).Offset(1, 0) = Cell.Address
Sheets("Link List").Cells _
(65536, 3).End(xlUp).Offset(1, 0) = Cell.Formula
Else

End If
Next Cell
End If 'Not LinkCells Is Nothing
Next sht
End Sub

Posted by Dave Hawley on May 01, 2001 1:25 PM

Hi Steve

If you place it within an Add-in you will need to change "ThisWorkbook" to ActiveWorkBook.


Dave
OzGrid Business Applications

Posted by Dave Hawley on May 01, 2001 1:28 PM

Oh! I forgot

Seems like i used the wrong macro, it does indeed list All Formulas. Change the line to:

If Left(Cell.Formula, 3) = "='[" Then


Dave

OzGrid Business Applications



Posted by steve w on May 01, 2001 2:24 PM

Re: Oh! I forgot(Thanks dave)

If Left(Cell.Formula, 3) = "='[" Then