View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Whats wrong with this line of code?

I live and learn <vbg

Bob

"Tom Ogilvy" wrote in message
...
You can also do it this way:

Sub AddSheet()
range_s = "NewSheet"
Worksheets.Add(after:=Worksheets(Worksheets.Count) ).Name = range_s
End Sub

"Bob Phillips" wrote in message
...
Edgar,

Don't think you can name it and place it in one statement. Try

Set oWs = Worksheets.Add(after:=Worksheets(Worksheets.Count) )
oWs.Name = range_s


--

HTH

RP

"Edgar Thoemmes" wrote in

message
...
Worksheets.Add.name = range_s after:=Worksheets(Worksheets.Count)

Comes up with the error 'Compile error - Expected end of statement'

Thanks