intrigued_66
intrigued_66

Reputation: 17220

Creating a new excel workbook

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

Answers (1)

gparis
gparis

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

Related Questions