Reputation: 17220
Can someone please help me with the following code:
Dim NewOutputFile As Workbook
Set NewOutputFile = Workbooks.Add(FileName & ".xls")
where FileName = "C:\Documents and Settings\me\My Documents\file.xls"
I want to create a new workbook dynamically and then add new tabs:
NewOutputFile.Sheets.Add ("New tab")
EDIT when I say "workbook" I mean a new excel file
Upvotes: 3
Views: 46496
Reputation: 1267
NewOutputFile.Sheets.Add().Name= "New tab"
Or if you want to add a Worksheet as the last Worksheet:
NewOutputFile.Sheets.Add(After:=NewOutputFile.Sheets(NewOutputFile.Sheets.Count)).Name = "New tab"
Upvotes: 7