ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Whats wrong with this line of code? (https://www.excelbanter.com/excel-programming/314723-whats-wrong-line-code.html)

Edgar Thoemmes[_4_]

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

Bob Phillips[_6_]

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




Dana DeLouis[_3_]

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






Tom Ogilvy

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






Bob Phillips[_6_]

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









All times are GMT +1. The time now is 09:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com