VBA code to save as entire workbook in to same path with formulas value pasted

Balajibenz

Board Regular
Joined
Nov 18, 2020
Messages
80
Office Version
  1. 2013
Platform
  1. Windows
Hi,

Can someone help me on how save the entire workbook in to same path as source workbook with the formulas alone value pasted and leaving all other formatting.

I am using blow line of code to save the file. Also help me to save the file even if there is an existing file in the path with same name.

ActiveWorkbook.SaveAs ActiveWorkbook.Path & "\Filename_" & Format(Date, "dd-mmm-yy") & ".xlsb", xlExcel12
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
How many sheets do you have in the workbook?
 
Upvote 0
Try this:
VBA Code:
Sub MySave()

    Dim ws As Worksheet
    
'   Look through each sheet and hard-code formulas
    For Each ws In ActiveWorkbook.Worksheets
        ws.Activate
        ActiveSheet.UsedRange.Value = ActiveSheet.UsedRange.Value
    Next ws
    
'   Save workbook
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs ActiveWorkbook.Path & "\Filename_" & Format(Date, "dd-mmm-yy") & ".xlsb", xlExcel12
    Application.DisplayAlerts = True
    
End Sub
 
Upvote 0
Solution
Try this:
VBA Code:
Sub MySave()

    Dim ws As Worksheet
   
'   Look through each sheet and hard-code formulas
    For Each ws In ActiveWorkbook.Worksheets
        ws.Activate
        ActiveSheet.UsedRange.Value = ActiveSheet.UsedRange.Value
    Next ws
   
'   Save workbook
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs ActiveWorkbook.Path & "\Filename_" & Format(Date, "dd-mmm-yy") & ".xlsb", xlExcel12
    Application.DisplayAlerts = True
   
End Sub
Worked perfectly, thanks mate
 
Upvote 0
You are welcome.
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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