Name of sheet from cell?

damian_r_Home

Board Regular
Joined
Jan 8, 2005
Messages
231
Office Version
  1. 365
  2. 2007
Platform
  1. Windows
Hi

Is it possible for the name of the sheet to be automatically taken from a a cell within that sheet?

If it is and its coding that does it, can you please give me exacting step by step guide on how you do it.

Hope you understand what i'm on about.


Damian
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Right click on the worksheet, select view code and paste this code in the module window.
Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Dim NameRange As Range
Set NameRange = Range("A1")
If Not Intersect(Target, NameRange) Is Nothing Then
    On Error Resume Next
    ActiveSheet.Name = NameRange
    If ActiveSheet.Name <> NameRange Then
        MsgBox "Unable to change name"
    End If
End If
End Sub
This will change the worksheet to the value in A1.

Does this help?
 
Upvote 0
Sans VBA --

=RIGHT(CELL("filename",A1),LEN(CELL("filename",A1))-FIND("]",CELL("filename",A1)))

Note: The reference to A1 can be used anywhwere in the sheet, the formula just needs a/any reference to operate upon.
 
Upvote 0
JJ - the OP is looking to change the sheet name to whatever's entered in an input cell (if I understand correctly). :cool:
 
Upvote 0
Barrie Davidson said:
JJ - the OP is looking to change the sheet name to whatever's entered in an input cell (if I understand correctly). :cool:

Well, call me just_dense. :biggrin:
 
Upvote 0
WOW!!!

Thanks for the help on this guys.

I'll give it a whirl over the next few days and see what i get.

Thanks again


Damian
 
Upvote 0
autigers said:
It doesn't like a date ..... ex ... 12-18 returns "Unable to change name"

How about changing to
Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Dim NameRange As Range
Set NameRange = Range("A1")
If Not Intersect(Target, NameRange) Is Nothing Then
    On Error Resume Next
    ActiveSheet.Name = CStr(NameRange)
    If ActiveSheet.Name <> NameRange Then
        MsgBox "Unable to change name"
    End If
End If
End Sub
 
Upvote 0
HI again.

If I add a value to the target cell that is alphabetical, everything works fine.
If I add a value to the target cell that is alphabetical then numerical (or vies versa), everything works fine.
However, if you enter just a numerical value, the sheet name does change even though you get an error message popping up. Can we either make the numerical value work so the pop up error message doesn’t happen, or perhaps turn off the error message?

Your help again would be appreciated.


Damian
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,818
Members
449,049
Latest member
cybersurfer5000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top