Option Explicit
Sub ListAllFormulas()
Dim sht As Worksheet
Dim shtName
Dim myRng As Range
Dim newRng As Range
Dim c As Range
ReTry:
shtName = Application.InputBox("Choose a name for the new sheet to list all formulas.", "New Sheet Name", "_AllFormulas")
If shtName = False Then Exit Sub
On Error Resume Next
Set sht = Sheets(shtName)
If Not sht Is Nothing Then
MsgBox "This sheet already exists"
Err.Clear
Set sht = Nothing
GoTo ReTry
End If
Worksheets.Add.Move after:=Worksheets(Worksheets.Count)
Application.ScreenUpdating = False
With ActiveSheet
.Range("A1").Value = "Formula"
.Range("B1").Value = "Sheet Name"
.Range("C1").Value = "Cell Address"
.Name = shtName
End With
For Each sht In ActiveWorkbook.Worksheets
If sht.Name <> shtName Then
Set myRng = sht.UsedRange
On Error Resume Next
Set newRng = myRng.SpecialCells(xlCellTypeFormulas)
For Each c In newRng
If (Not c Is Nothing) Then
If (Len(c.Formula) > 1) Then
Sheets(shtName).Range("A65536").End(xlUp).Offset(1, 0).Value = VBA.Strings.Mid(c.Formula, 2, (Len(c.Formula)))
Sheets(shtName).Range("B65536").End(xlUp).Offset(1, 0).Value = sht.Name
Sheets(shtName).Range("C65536").End(xlUp).Offset(1, 0).Value = Application.WorksheetFunction.Substitute(c.Address, "$", "")
End If
End If
Next c
End If
Next sht
Sheets(shtName).Activate
ActiveSheet.Columns("A:C").AutoFit
Application.ScreenUpdating = True
End Sub
|