Wednesday, March 21, 2012

How to Add a New Workbook in VBA


1. Press the 'Alt' and 'F11' keys together in your workbook to open the Visual Basic Editor (VBE).
2. Click 'Insert' and then click 'Module' to open a blank module window.
3. Type the following:Sub AddNew()Set NewBook = Workbooks.AddWith NewBook.Title = 'All Sales'.Subject = 'Sales'.SaveAs Filename:='Allsales.xls'End WithEnd Sub
4. Press 'F5' to run the program and open a new workbook.

Blogger news