VB and VBA Users Source Code: Extracting the formulas from an Excel range to a string
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Extracting the formulas from an Excel range to a string
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Wednesday, October 29, 2003
Hits:
1671
Category:
Unspecified
Article:
The following code can be used to extra a formula/equation from an Excel range into a string. 'Purpose : Extracts the formulas from a range of cells into a string 'Inputs : rngSource The range to extract the formula from. 'Outputs : Returns a string containing the formula/s 'Author : Andrew Baker 'Date : 31/12/2000 13:51 'Notes : 'Revisions : Function FormulasText(rngSource As Excel.Range) As String Dim avFormulas As Variant, avFormula As Variant On Error GoTo ErrFailed Application.Volatile True FormulasText = "" avFormulas = Empty avFormulas = rngSource.SpecialCells(xlFormulas).Formula If IsArray(avFormulas) Then For Each avFormula In avFormulas FormulasText = FormulasText & avFormula & " " Next Else FormulasText = avFormulas End If 'Extract the formulas FormulasText = Trim(FormulasText) Exit Function ErrFailed: Debug.Print Err.Description Debug.Assert False FormulasText = "" End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder