VBA Code to Save a WorkSheet to a New File Using Cell Ranges to define Sheet and File

Daveychops

New Member
Joined
Mar 25, 2019
Messages
3
Hi there, I hope this request finds you well and in super fine spirits today ;).

I have searched through the archive and see that there are plenty of excellent solutions but not one that fits all my requirements (i'm just such a control freak!). This is my first request so apologies if anything is amiss.

I use Microsoft Office Excel 365 Pro Plus have a file that contains sorted data in a number of worksheets and would like a flexible macro to save an individual worksheet (with a defined name using a cell's content) to a separate file (with a defined location & name using two cell's contents)

Cell A1 will have the location to be saved "C:\..."
Cell A2 will have the file name to be saved "Monthend..."
Cell A3 will have the name of the worksheet (to be isolated and saved as a file) "Closed..."

That is the basic requirement and would be brilliant to have solved in itself; however, if there is an extra challenge you're game for...could you add in a pop up window that would ask for the worksheet name (that would be stored in cell A3).

Cheers again, have a nice one. Dave ;)
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi & welcome to MrExcel
How about something like
Code:
Sub Daveychops()
   Dim Ws As Worksheet
   
   Set Ws = ActiveSheet
   Sheets(Ws.Range("A3").Value).Copy
   ActiveWorkbook.SaveAs Ws.Range("A1").Value & Ws.Range("A2").Value, 52
End Sub
 
Last edited:
Upvote 0
Hi & welcome to MrExcel
How about something like
Code:
Sub Daveychops()
   Dim Ws As Worksheet
   
   Set Ws = ActiveSheet
   Sheets(Ws.Range("A3").Value).Copy
   ActiveWorkbook.SaveAs Ws.Range("A1").Value & Ws.Range("A2").Value, 52
End Sub

Ahhh awesome stuff, such a small thing that does a great job (as my girlfriend keeps telling me) thank you, have a nice day
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,909
Messages
6,122,189
Members
449,072
Latest member
DW Draft

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