VBA to create new workbook with a pre-defined name

csilabgirl

Active Member
Joined
Aug 14, 2009
Messages
359
Excel 2002

I have a workbook where I would like to run some VBA code that will open a new workbook and then name the new workbook based on some text in a particular cell in the first workbook. Is this possible. Right now, it just names it book 1, book 2, book 3, etc.

Thank you for the help
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Try like this

Code:
Sub NewWb()
Dim Aname As String
Aname = ActiveWorkbook.Sheets(1).Range("A1").Value
Workbooks.Add
ActiveWorkbook.SaveAs Filename:=Aname & ".xls"
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,555
Members
452,928
Latest member
101blockchains

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