Save worksheet

VbaHell

Well-known Member
Joined
Jan 30, 2011
Messages
1,220
Hello one and all

I am using excel 2007

Is it possible please to do the following with VBA code
I have a workbook with 4 worksheets, I want to be able to Click on cell B1 and then save that worksheet only in a folder c:\mydocuments\B1 (Name in B1 cell)
Then delete the save worksheet from the workbook and then save the workbook as c:\mydocuments\VBA
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Maybe you can try something like this....
Code:
[FONT=Courier New]Sub TEST()[/FONT]
[FONT=Courier New]Dim myworkbook As Workbook[/FONT]
[FONT=Courier New]Worksheets("Sheet1").Copy[/FONT]
[FONT=Courier New]Set myworkbook = ActiveWorkbook[/FONT]
[FONT=Courier New]myworkbook.SaveAs "Your Folder Path here \" & Range("B1").Value & ".xls"[/FONT]
[FONT=Courier New]myworkbook.Close[/FONT]
[FONT=Courier New]End Sub[/FONT]
 
Upvote 0
Hi Pedie

Can I ask please, I want to only save the worksheet not the whole workbook
 
Upvote 0
Did you try it out?:) if 2007 format...try this way.
this will only save sheet1 for example. you can replace sheet1 with your sheet name.....
Code:
[FONT=Courier New]Dim myworkbook As Workbook[/FONT]
[FONT=Courier New]Sheets("Sheet1").Copy'[/FONT]
[FONT=Courier New]Set myworkbook = ActiveWorkbook[/FONT]
[FONT=Courier New]myworkbook.SaveAs "C:\.......\" & Range("B1").Text & "xlsm", FileFormat _[/FONT]
[FONT=Courier New]       :=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False[/FONT]
[FONT=Courier New]myworkbook.Close[/FONT]
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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