ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Name a New Workbook (https://www.excelbanter.com/excel-programming/411747-name-new-workbook.html)

Yuanhang

Name a New Workbook
 
In a macro, I have a main workbook open where I run the Macro.

What I want the macro to do is adding a few new workbooks (around 10 new
workbooks), and then name them according to a list of names (F2:F11) in the
main workbook.

Is there any way to guide me to this? Thank you.



Norman Jones[_2_]

Name a New Workbook
 
Hi Yuanhang,

In a standard module, try:


'============
Option Explicit
Public Sub Tester001()
Dim WB As Workbook
Dim newWB As Workbook
Dim SH As Worksheet
Dim Rng As Range
Dim rCell As Range

Set WB = Workbooks("myBook.xls") '<<===== CHANGE
Set SH = WB.Sheets("Sheet1") '<<===== CHANGE
Set Rng = SH.Range("F2:F11") '<<===== CHANGE

On Error GoTo XIT
Application.ScreenUpdating = False

For Each rCell In Rng.Cells
Set newWB = Workbooks.Add
With newWB
.SaveAs Filename:=rCell.Value, _
FileFormat:=xlWorkbookNormal
.Close SaveChanges:=False
End With
Next rCell

XIT:
Application.ScreenUpdating = True

End Sub
'<<============



---
Regards.
Norman
"Yuanhang" wrote in message
...
In a macro, I have a main workbook open where I run the Macro.

What I want the macro to do is adding a few new workbooks (around 10 new
workbooks), and then name them according to a list of names (F2:F11) in
the
main workbook.

Is there any way to guide me to this? Thank you.





All times are GMT +1. The time now is 01:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com