View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
STEVE BELL STEVE BELL is offline
external usenet poster
 
Posts: 692
Default Convert formulas to values on save

Steve,

My approach would be to copy each worksheet to a new workbook. (This
prevents any code staying with the workbook.)

Just record code:
Creat a new workbook
Copy a worksheet in the template
Paste Special Values to the next workbook

Repeat for all sheets you want.

Than modify the code.

You can set the code to copy/paste simple ranges, or entire worksheets.

You can loop through all the worksheets (if you have multiple worksheets.


You can put the code in a standard module or you can put it into the
ThisWorkbook Module.
(This sample only copy all the cells on the active sheet and replaces the
formulas with values.)

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cells.Copy
Cells.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End Sub

Let us know if this helps...

--
steveB

Remove "AYN" from email to respond
"Steve B" wrote in message
...
I have a template which draws values from formulas that reference other
workbooks. Is there a way, on save, to convert all formulas to values so
the
new workbook is a 'snapshot' that can be distributed without needing the
reference to the linked files?

TIA, Steve