Search TeachExcel.com
TeachExcel.com
TE
Teach Excel MS Office Tutorials Excel Consulting Services Excel Forum
Excel Video Tutorials Excel Tips Free Excel Macros Excel Help Resources Contact TeachExcel
Video Tutorials
  • Free Macros
  • Excel Help Directory
  • Excel 2007 Resources
  • Keyboard Shortcuts
  • Excel Forum
  • Contact/About

Macros
Excel Tutorials For Macros

Replace Formulas with Values (For The Entire Workbook)


Bookmark and Share

This macro will convert every formula in an entire workbook into its respective value. This is basically a quick way to replace to do a copy-paste values except that nothing is moved or re-arranged. Just make sure to remember that this one will not only work on the active sheet, but on the entire open workbook. This is a good thing to use if you are distributing your workbook and you don't want the recipients to know how you did something or where certain numbers came from.
Where to install the macro:  Module

Replace Formulas with Values (Entire Workbook)

Sub FormulasToValues_EntireWorkbook()

'This Macro will replace all formulas from an entire workbook
'with their respective values. It will just changes all
'formulas to values.

WCount = Worksheets.Count
For i = 1 To WCount
If Worksheets(WCount - i + 1).Visible Then
Worksheets(WCount - i + 1).Select
RCount = ActiveCell.SpecialCells(xlLastCell).Row
CCount = ActiveCell.SpecialCells(xlLastCell).Column
For j = 1 To RCount
For k = 1 To CCount
Worksheets(WCount - i + 1).Cells(j, k) = Worksheets(WCount - i + 1).Cells(j, k).Value
Next k
Next j
End If
Next i

End Sub


Bookmark and Share


How to Install the Macro
  1. Select and copy the text from within the grey box above.

  2. Open the Microsoft Excel file in which you would like the Macro to function.

  3. Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.  Or For other ways to get there, Click Here.

      For Excel Versions Prior to Excel 2007
      Go to Tools > Macros > Visual Basic Editor

      For Excel 2007
      Go to Office Button > Excel Options > Popular > Click Show Developer tab in the Ribbon. Then go to the Developer tab on the ribbon menu and on the far left Click Visual Basic

  4. On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.

  5. If the Macro goes in a Module, Click Here, otherwise continue to Step 8.

    1. Go to the menu at the top of the window and click Insert > Module
    2. Another window should have opened within the Visual Basic Editor's window. Within this new window, paste the macro code. Make sure to paste the code underneath the last line of anything else that is in the window.
    3. Go to Step 8.

  6. If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.

    1. Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
    2. Then, at the bottom of the list that appears, double-click the ThisWorkbook text.
    3. A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
    4. Go to Step 8.

  7. If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.

    1. Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
    2. Within the list that appears you will see every worksheet that is in that excel file. They will be listed as such: Sheet1(NAME OF SHEET HERE) and under that will be Sheet2(NAME OF SHEET HERE). Select the sheet in which you want the macro to run and double-click that sheet.
    3. A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
    4. Repeat steps b and c for every sheet you want the macro to work in. Putting the macro in one sheet will not enable it for any other sheets in the workbook.
    5. Go to Step 8.

  8. Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.

  9. You are now ready to run the macro.



Similar Helpful Excel Resources

Find & Replace In Entire Workbook? - Excel

View Content
Title pretty much says it all....

I have to change drive letters in all the links in 200+ worksheets. A Find & Replace that can do it in one go sure would be helpful... is there any trick that might help me out?

Find & Replace - Entire Workbook With A Twist - Excel

View Content
Excel 2007 - VBA Code Help

I have a workbook with many different worksheets containing data. I am looking to find a certain city name in each worksheet and then replace the region name immediately to the left of the city name.

Example:

Befo

Region City
SCAL ALBUQ

After:

Region City
SCAL_O ALBUQ

Thanks in advance

Macro To Find/replace Across Entire Workbook (an Easy One) - Excel

View Content
I think I'm having a brain fart/computer gremlin...

A macro that has always worked for me, a simple find and replace across the entire workbook:
Cells.Replace What:="#N/A", Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

is now only find/replacing for the active sheet...

Is my "LookAt:=" wrong?

thanks everyone.

Removing Formulas From Entire Workbook Consisting Of Multiple Sheets - Excel

View Content
I have multiple sheets in a workbook that all contain formulas. I need to remove ALL formulas on a regular basis and email to various users. Is there a way to automate this process so that I'm not copy/paste values on each worksheet?

Replace Values In Formulas - Excel

View Content
Hi there,

First time posting but i need your guys help.

Please see the attached file for the problem i am having.

I have a discounted total and am trying to remove the discount to gain the original amount then apply new discount factors to the undicounted amount to get a new value, although when i apply the same discount factors there is a difference. I think its to do with the 100+10%=110 -10%=99 type thing, but am not sure and my brain hurts.

Any help appreciated.

Kind Regards

Joe

Function To Replace Formulas With Values - Excel

View Content
Hi,
I have a workbook, multiple sheets, and within each sheet there are multiple cells with formulas in. I want to write a function to replace any cell which has a formula, with the value in the cell. Tried find and replace macro, but seems very messy. Any suggestions please?
Thanks in advance

Using Find Replace For Values & Not Formulas - Excel

View Content
I'm trying to remove all zero amounts from an Excel spreadsheet converted from my bookkeepping program. All of the zero amounts read "0.00" but I would prefer them to be blank so actual income expense activity is easier to spot. When I use Edit/Find it allows looking for - Formulas, Values & Comments in the "Look in:" field. However when I try to use the Find & Replace it only allows "Formulas" in the "Look in:" field. This returns a window that says it cannot find any occurances of "0.00" (because there are no formulas on worksheet). Why won't it allow Find & Replace of Values? Is there another way to approach this other than manually deleting the offending zeros?

Vba Find And Replace Values With Formulas - Excel

View Content
I am stuck on a section of my macro. I have come to a spot where in column C I have values ranging from 0-999 never in the same order or number of records, Any value that is less than 10 I need to replace with the sum of the adjacent cells in column A+B. example C5 = sum A5+B5.

I am not sure if the find and replace function is correct for what I need to do. I was also looking at filtering the

How To Save An Entire Workbook, But Only Values? - Excel

View Content
I have a very large XL workbook, with 20+ worksheets and many complex formulas, which has grown to over 35 MB. I want to distribute it to other people, but only the values, to keep the file light.

Is there any way to save entire the file with just the values? (without having to go worksheet by worksheet and doing Copy -> Paste Values)?

A solution not involving macros is preferred. Thanks!!

-Alejandro

Vba Paste Entire Workbook Contents As Values - Excel

View Content
In an effort to remove calculations from a workbook, I am trying to paste over the entire contents of each sheet as values, replacing the formulas.

I have multiple sheets, so I would like to have this done via Macro.

I have tried the following, with no success and I'm not sure what is wrong.

Thoughts?

Sub ExternalValues()
Dim ws As Worksheet
' Sheets(1).Select
For Each ws In ActiveWorkbook.Worksheets
ws.Select
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Select
Next ws
End Sub

Random Tutorials
Net Present Value / Discounted Cash Flow Calculations
(Intermediate)
Extract Text from Cells - Intermediate Example
(Intermediate)
Introduction to Making Formulas in Excel
(Easy)
Function and Formulas Lookup in Excel
(Easy)
AND(), OR(), and IF() Statements/Formulas
(Intermediate)
Absolute and Relative Cell References
   - & INDIRECT() Function Introduction

(Easy)
Submit Inquiry Here
  • Prices From $10
Name:*
E-mail:*
Request:*
The macro(s) on this page will be sent with the request.
Contact | Privacy Policy | Disclaimer
Copyright© 2012 TeachExcel.com