VideoPhoto

12 October, 2021

Extract Formulas to External File

If your workbook/worksheet is full of Excel formulas it may be worth to keep track of them in one place, in a compact listing, in a separate text file.

Here is a simple short macro that serves the purpose:

Sub ListFormulas()
Dim rng As Range
'Extracts all formulas from a worksheet to a text file (Notepad/Wordpad)
Open "C:\Users\Adam\Desktop\XFormulas.txt" For Output As #1
For Each rng In Sheets("Formulas").UsedRange.Cells
If rng.Formula <> "" And Left(rng.Formula, 1) = "=" Then
           Print #1, rng.Address; Tab; rng.Formula
End If
Next
Close #1
End Sub

Just copy it and paste into one of the VBE modules of your workbook (I'd recommend Personal workbook), to make the macro easily available for copying - whenever you need it - to any of your workbooks.

Remember to replace the path to your text file and the sheet name in the macro, with your own.

It extracts all formulas from a worksheet and writes them into a text file, in the following format (example):

If your formulas are spread over multiple worksheets of your workbook, the macro can be easily modified to loop through all of the worksheets.

 

No comments:

Post a Comment

All comments are held for moderation. I reserve the right to edit, censor, delete and - if necessary - block comments.