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 - 30 May 2008 03:37 GMT
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
> In a macro, I have a main workbook open where I run the Macro.
>
[quoted text clipped - 4 lines]
>
> Is there any way to guide me to this? Thank you.