View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Kevin Stecyk Kevin Stecyk is offline
external usenet poster
 
Posts: 74
Default Worksheets.Add method

Sorry, ignore me and accept Ron's solution.


"Kevin Stecyk" wrote in message
...
Hi Bruce,

You just had a typo...

oSht = oDoc.Worksheets.Add

should be

Set oSht = oDoc.Worksheets.Add

HTH

Regards,
Kevin


"Bruce Lindsay" wrote in message
...
I have tried to add a worksheet with the following code.

dim oDoc as Workbook
dim oSht as Worksheet

Set oDoc = Application.ThisWorkbook
oSht = oDoc.Worksheets.Add

It gives an error #1004. I have tried it in many variations but all

fail.
Some even create the sheet but still error out. Any help would be
appreciated.