We're aware that some users are experiencing technical issues which the team are working to resolve. See the Community Noticeboard for more info. Thank you for your patience.
📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

How to make Sheet1 the same as a Cell in Excel

Options
Hi,

I have a spreadsheet on Excel and I am wanting it to copy the cell information ie a date - 01.01.18 to replace the Sheet tab at the bottom.


Example


Cell E4 '01.01.18' needs to make sheet1 read '01.01.18'

Many thanks for any help.
«1

Comments

  • neilmcl
    neilmcl Posts: 19,460 Forumite
    Part of the Furniture 10,000 Posts Name Dropper
    You can do it via VBA.

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Set Target = Range("E4")
    If Target = "" Then Exit Sub
    Application.ActiveSheet.Name = VBA.Left(Target, 31)
    Exit Sub
    End Sub
  • DoaM
    DoaM Posts: 11,863 Forumite
    10,000 Posts Fifth Anniversary Name Dropper Photogenic
    It's been a long time since I've done any VBA, but ... why the 2nd Exit Sub? Doesn't End Sub do the same thing?
  • neilmcl
    neilmcl Posts: 19,460 Forumite
    Part of the Furniture 10,000 Posts Name Dropper
    DoaM wrote: »
    It's been a long time since I've done any VBA, but ... why the 2nd Exit Sub? Doesn't End Sub do the same thing?
    There is a difference but your right it doesn't need to be there, bad cut & paste.
  • Robj241
    Robj241 Posts: 29 Forumite
    Part of the Furniture 10 Posts
    Thanks for the info.

    So do I highlight the cell E3
    Click on Macro - Visual Basic Editor
    Click the drop down menu and select Worksheet
    Type in the info provided
    Then save?

    Many thanks
  • GunJack
    GunJack Posts: 11,828 Forumite
    Part of the Furniture 10,000 Posts Name Dropper Photogenic
    ...or just right-click on the tab you want, and select "rename" ?
    ......Gettin' There, Wherever There is......

    I have a dodgy "i" key, so ignore spelling errors due to "i" issues, ...I blame Apple :D
  • Thing is you need some sort of event to trigger the renaming and If you are happy to right click then just
    Right Click Cell/Copy
    Right Click Tab/Rename/CTRL+V

    The problem with the macro is that it renames the Tab EVERY TIME you select a cell (event trigger) for ever and ever amen
    If I ruled the world.......
  • neilmcl
    neilmcl Posts: 19,460 Forumite
    Part of the Furniture 10,000 Posts Name Dropper
    Robj241 wrote: »
    Thanks for the info.

    So do I highlight the cell E3
    Click on Macro - Visual Basic Editor
    Click the drop down menu and select Worksheet
    Type in the info provided
    Then save?

    Many thanks
    Just right-click the sheet name, select View Code and copy the code I provided into the VBA editor that pops up.. Click Save and exit the VBA editor and away you go. The excel doc, however, must be saved as a Macro enabled worksheet (*.xlsm).
  • Robj241
    Robj241 Posts: 29 Forumite
    Part of the Furniture 10 Posts
    Unfortunately this comes up as an error.

    The Cell E3 contains a date - 01/01/18 but it won't allow /

    Is there a way round this?

    Many thanks for your assistance.
  • rmg1
    rmg1 Posts: 3,159 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    If you don't want the code to run every time you change cells (which will be annoying) then try this:-
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$E$4" Then
    Application.ActiveSheet.Name = VBA.Left(Target, 31)
    End If
    End Sub

    It will fire every time you change a cell but won't do anything unless you're in cell E4.
    :wall: Flagellation, necrophilia and bestiality - Am I flogging a dead horse? :wall:

    Any posts are my opinion and only that. Please read at your own risk.
  • neilmcl
    neilmcl Posts: 19,460 Forumite
    Part of the Furniture 10,000 Posts Name Dropper
    Robj241 wrote: »
    Unfortunately this comes up as an error.

    The Cell E3 contains a date - 01/01/18 but it won't allow /

    Is there a way round this?

    Many thanks for your assistance.
    Could always convert the date to something like 01 Jan 2018.
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 350.8K Banking & Borrowing
  • 253K Reduce Debt & Boost Income
  • 453.5K Spending & Discounts
  • 243.8K Work, Benefits & Business
  • 598.6K Mortgages, Homes & Bills
  • 176.8K Life & Family
  • 257K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16.1K Discuss & Feedback
  • 37.6K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.