VB and VBA Users Source Code: Replacing the formulas from an Excel Range with their values
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Replacing the formulas from an Excel Range with their values
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Monday, March 17, 2003
Hits:
1244
Category:
Unspecified
Article:
The following code will remove all the formulas from an Excel range and replace them with the values of the formula. Option Explicit 'Purpose : Takes an Excel Range containing formulas and replaces/overwrites the formulas with their values. 'Inputs : oFormulaRange The range containing the formulas to remove. 'Outputs : Returns True on success, False of failure. 'Author : Andrew Baker 'Date : 13/11/2002 10:14 'Notes : 'Revisions : Function RangeToValues(oFormulaRange As Excel.Range) As Boolean Dim avValues As Variant On Error GoTo ErrFailed avValues = oFormulaRange.Value oFormulaRange.Value = avValues RangeToValues = True Exit Function ErrFailed: Debug.Print Err.Description Debug.Assert False RangeToValues = False End Function 'Demonstration routine Sub Test() RangeToValues ActiveSheet.Range("A1:A10") End Sub
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder