Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Whats wrong with this line of code?

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

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

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Whats wrong with this line of code?

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Whats wrong with this line of code?

Putting the "name" at the end should do it.

Worksheets.Add(After:=Worksheets(Worksheets.Count) ).Name = "Test"

--
Dana DeLouis
Win XP & Office 2003


"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





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Whats wrong with this line of code?

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





  #5   Report Post  
Posted to microsoft.public.excel.programming
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









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Whats Wrong with this?? drvortex Excel Worksheet Functions 1 October 30th 04 06:48 PM
whats wrong with this code LiSa Excel Programming 2 September 8th 04 05:47 PM
Whats wrong? Lee Excel Programming 0 July 14th 04 05:04 PM
Whats wrong with this code gav meredith Excel Programming 5 April 21st 04 12:01 AM
What's wrong with this line of code? Sandy[_3_] Excel Programming 0 July 23rd 03 12:15 PM


All times are GMT +1. The time now is 03:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"