Share via

Method 'Add' of object 'Sheet' failed error

Anonymous
2021-08-09T23:08:24+00:00

What am I doing wrong here:

Sub createGPREC_outputFile()

Dim newWB As Workbook

Set newWB = Workbooks.Add

Worksheets.Add After:=Sheet1, Count:=3

End Sub

All I am trying to do is create a New Workbook with 4 sheets, and give each sheet a new name. But I am getting an error on the highlighted line above.

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2021-08-10T01:05:29+00:00

re: add new workbook

This just worked for me...
'---

Sub createGPREC_outputFile()
Dim newWB As Excel.Workbook

Set newWB = Application.Workbooks.Add
newWB.Worksheets.Add After:=Sheet1, Count:=3

End Sub
'---

NLtL

https://1drv.ms/u/s!Au8Lyt79SOuhZw2MCH7_7MuLj04?e=sAwbHU

(free excel programs)

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Most helpful