Adding Worksheets

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

Hi

I am creating an Add-in. This Add-in functions will run on
top of a workbook of data. How do I add a new worksheet in
active workbook with the name "Result" from a function in
the Add-In.
I tried the following but it does not work
ThisWorkBook.Sheets.Add

Also how to ensure that it already does not exist

I use Excel 2002 on Win 2000

Please advise
Thanks a lot
 
Try this:

Set NewSheet = ActiveWorkbook.Sheets.Add
NewSheet.Name = "Results"

Regards,
Patricia
 
With Activeworkbook.Worksheets
.Add(after:=.count).Name = "ABCD"
End With
 
Hi Tom
It gives out the follwoing error

Method add of object 'sheets' failed

Please advise
also once its working how not to add (trap error) if the
name already exist.

Thanks a lot in advance for your help
 
Thanks a lot it worked
-----Original Message-----
Try this:

Set NewSheet = ActiveWorkbook.Sheets.Add
NewSheet.Name = "Results"

Regards,
Patricia run worksheet
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top