Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel to replace formulas with values

Tags:

excel

vba

I have an Excel workbook (1) with around 9 sheets that is pulling in and manipulating data from a second workbook (2).

After pulling in the data from workbook (2) I need to be able to replace the formulas in workbook (1) to the resulting values that the formulas have produced, from here I will then save the workbook (1) with the results.

Is there a macro that can do this for me?

like image 801
Alex Avatar asked Jun 08 '15 19:06

Alex


People also ask

How do I convert a formula to a value in Excel without copying?

👉 You can press SHIFT + F10 simultaneously, and then press V on your keyboard to convert the formula to value without paste special.

How do I convert a formula to a value in multiple cells?

Converting formulas to values using Excel shortcuts Select all the cells with formulas that you want to convert. Press Ctrl + C or Ctrl + Ins to copy formulas and their results to clipboard. Press Shift + F10 and then V to paste only values back to Excel cells.

How do you remove formula but keep value?

Delete a formula but keep the results Select the cell or range of cells that contains the formula. Click Home > Copy (or press Ctrl + C). Click Home > arrow below Paste > Paste Values.


1 Answers

On your new workbook some basic code such as:

Sub Value()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Sheets
    ws.UsedRange.Value = ws.UsedRange.Value
Next
End Sub
like image 57
brettdj Avatar answered Sep 20 '22 14:09

brettdj