Macro to save 2 sheets in a work book (not all 6) with no formulas to reduce file size

fishep6

New Member
Joined
Feb 10, 2014
Messages
43
I have a spreadsheet which is 64000kb which I want to use asa data base. What happens is the user opens this, input an account number andseveral lookups extract data based on that account and then the database issaved as a duplicate copy but naming it using a set file name “D2” and in a setlocation “A2”. The sub I have is below.

Private Sub CommandButton3_Click()

Dim SaveName As String
SaveName =ActiveSheet.Range("d2").Text
ActiveWorkbook.SaveAs Filename:=ActiveSheet.Range("A2") &_
SaveName& ".xlsb"

End Sub

Obviously the file size is an issue and I need a Macro thatreduces the file size dramatically but after googling various answers I cantget what I need.

My workbook has 8 sheets in it but most of this is thedatabase.

What I want it to do when saving is save sheet 1 (labelled “form”)and sheet 4 (labelled “import”), all the other 6 sheets I no longer need andcan be deleted.

I want sheets 1 and 4 to lock down the data (no longer needany formulas or macros) but do want to keep it formatted and looking the sameas the original on the surface. The other issue is that I have a range in sheet4 labelled “data” and need that range to remain labelled as such within the newsmaller saved file as I have another database that looks for that range name toimport data from.

Thanks for your help
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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