View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Is This A Bug????

Although I would use Worksheets rather than Sheets as Gary did, that code
worked fine for me adding 20 worksheets.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"EA" wrote in message
...
TradeWB.Sheets.Add After:=Worksheets(TradeWB.Sheets.Count)


I am adding worksheets to a WB using the above line. All I want to do is
add a new wks after the last wks in the book.

The line of code work for the first 16 iterations but causes a [Run-time
error '9' Subscript out of range] error on the 17th iteration.

The only way I can get the line to work after adding 16 worksheets is to

us
a :

TradeWB.activate statement before the above line of code.

I know this is a workaround, but is this a bug?

Can anyone tell me a way of adding worksheets, after the last current
worksheet without having to activate the workbook?

EA