SaveCopyAs but removing all formulas?

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
785
Office Version
  1. 365
Platform
  1. Windows
Hi,
I have a file I'm working on roughly 5MB with about 12 sheets and a lot of formulas.

I'm wanting to save a copy of the file often (values only) but want to do it as quick as possible.

SaveCopyAs is pretty quick but it saves an exact copy.
Where creating a copy of current workbook, removing formulas then saving is slower

How would you approach this?
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
I would use SaveCopyAs and replace formulas with values like this:
Code:
For Each ws In wb.Worksheets
    ws.UsedRange.Value = ws.UsedRange.Value
Next ws
 
Upvote 0
Where creating a copy of current workbook, removing formulas then saving is slower

How exactly are you doing this, doing the savecopyas, then on the copy selecting all sheets then selecting all cells and doing a copy/paste as values?
 
Upvote 0
@MARK858
I was creating a copy of current workbook then looping through each sheet and setting value=value

But now I have this which will work for me, I can create desperate file for each sheet and this is fast

Code:
Sub SaveasVals()
Dim WB1 As Workbook, WB2 As Workbook
Dim WS1 As Worksheet, WS2 As Worksheet

Application.ScreenUpdating = False
Application.DisplayAlerts = False

Set WB1 = ActiveWorkbook
Set WS1 = ActiveSheet
Set WB2 = Workbooks.Add
Set WS2 = WB2.Sheets("Sheet1")

CurDate = WS1.Range("P1").Value
MyDir = "C:\Users\test\Downloads\"

WS1.Cells.Copy
WS2.Cells.PasteSpecial Paste:=xlPasteValues

WB2.SaveAs MyDir & CurDate & ".xlsx"
WB2.Close

Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub
 
Last edited:
Upvote 0
Happy you have a solution but replacing
Code:
WS1.Cells.Copy
WS2.Cells.PasteSpecial Paste:=xlPasteValues
with
Code:
    With WS1.UsedRange
        WS2.Cells(1, 1).Resize(.Rows.Count, .Columns.Count).Value = .Value
    End With
should be faster.

The code above assumes the data in WS1 starts in row 1.
 
Upvote 0

Forum statistics

Threads
1,214,657
Messages
6,120,776
Members
448,991
Latest member
Hanakoro

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top