ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sheet Rename (day 2) (https://www.excelbanter.com/excel-programming/339885-sheet-rename-day-2-a.html)

Darin Kramer

Sheet Rename (day 2)
 
Guys...

Whats wrong with this vb...

Sub renmame_sheet()
Sheets("Master").Select
ActiveSheet.Name = Range("b2")
End Sub

I get a run time 1004 "application defined or object defined" error...??

*** Sent via Developersdex http://www.developersdex.com ***

DaveO

Sheet Rename (day 2)
 
It should work, but could be better to change Range("B2") to Range("B2").Value.

Is there a sheet called "Master". If not, then this will cause problems.

Also, is Range("B2") empty? If it is then there is no way this can work as a
sheet always has to be cleed something

"Darin Kramer" wrote:

Guys...

Whats wrong with this vb...

Sub renmame_sheet()
Sheets("Master").Select
ActiveSheet.Name = Range("b2")
End Sub

I get a run time 1004 "application defined or object defined" error...??

*** Sent via Developersdex http://www.developersdex.com ***


Darin Kramer

Sheet Rename (day 2)
 


Thanks - I had the .value in, but dropped it for somereason at a later
stage. Re-inserting it works perfectly :)

*** Sent via Developersdex http://www.developersdex.com ***

Bob Phillips[_6_]

Sheet Rename (day 2)
 
Do you have invalid values in B2, such as \, ? etc.? An y value that cannot
be used in a worksheet name.

--
HTH

Bob Phillips

"Darin Kramer" wrote in message
...
Guys...

Whats wrong with this vb...

Sub renmame_sheet()
Sheets("Master").Select
ActiveSheet.Name = Range("b2")
End Sub

I get a run time 1004 "application defined or object defined" error...??

*** Sent via Developersdex http://www.developersdex.com ***




DaveO

Sheet Rename (day 2)
 
HTH.

I would suggest somekind of validation in your code to make sure that
Range("B2") is both populated and does not use any special characters, like
Bob P refers to.

Only an idea.

"Darin Kramer" wrote:



Thanks - I had the .value in, but dropped it for somereason at a later
stage. Re-inserting it works perfectly :)

*** Sent via Developersdex http://www.developersdex.com ***



All times are GMT +1. The time now is 08:35 AM.

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