ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Naming a sheet (https://www.excelbanter.com/excel-programming/339792-naming-sheet.html)

Darin Kramer

Naming a sheet
 


Howdie,

I need to run a macro from within a sheet (currently called data), that
does several things to the sheet, the last being to rename the sheet to
the contents of cellb2.
Whats the vb to rename a sheet to b2...?

Thanks

D

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

Tom Ogilvy

Naming a sheet
 
activesheet.name = Range("B2").Value

--
Regards,
Tom Ogilvy


"Darin Kramer" wrote in message
...


Howdie,

I need to run a macro from within a sheet (currently called data), that
does several things to the sheet, the last being to rename the sheet to
the contents of cellb2.
Whats the vb to rename a sheet to b2...?

Thanks

D

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




Don Guillett[_4_]

Naming a sheet
 
try

Sub renmamethissheet()
ActiveSheet.Name = Range("b2")
End Sub

--
Don Guillett
SalesAid Software

"Darin Kramer" wrote in message
...


Howdie,

I need to run a macro from within a sheet (currently called data), that
does several things to the sheet, the last being to rename the sheet to
the contents of cellb2.
Whats the vb to rename a sheet to b2...?

Thanks

D

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



Peter Rooney

Naming a sheet
 
Darin,

This should do - paste it into the Code module of the "Data" worksheet

Whenever you change the value in the cell with the name "TabName" (you can
replace this with a cell reference if you want), the tabname will change to
that value, renaming the worksheet accordingly.

Regards

Pete



Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False

If Target.Address = Range("TabName").Address Then
Me.Name = Format(Target.Value)
End If
ws_exit:
Application.EnableEvents = True

End Sub

"Darin Kramer" wrote:



Howdie,

I need to run a macro from within a sheet (currently called data), that
does several things to the sheet, the last being to rename the sheet to
the contents of cellb2.
Whats the vb to rename a sheet to b2...?

Thanks

D

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



All times are GMT +1. The time now is 10:34 AM.

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