A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Name a worksheet tab based on the value in a cell.



 
 
Thread Tools Display Modes
  #1  
Old April 2nd, 2010, 06:27 PM posted to microsoft.public.excel.misc
Christine
external usenet poster
 
Posts: 402
Default Name a worksheet tab based on the value in a cell.

Hello all,

I have found a lot of posts about how to populate a cell with the value in
the worksheet tab name, but not the other way around. I would like to
automatically name the worksheet tab based on the value in a specific cell.

I'm ok with formula's but not "up" on VB. Is there a formula I could use to
accomplish this?

Thanks in advance for any help you can give me.

Christine
  #2  
Old April 2nd, 2010, 06:48 PM posted to microsoft.public.excel.misc
Roger Govier[_8_]
external usenet poster
 
Posts: 338
Default Name a worksheet tab based on the value in a cell.

Hi Christine

These 2 subs will do the task.
The first will just name the Active Sheet.
The second will run through the file and name all sheets according to
the value in cell A1 - provided A1 contains a value.

Sub NameSheet()
If Range("A1") "" Then
ActiveSheet.Name = Range("A1").Value
End If

ActiveSheet.Name = Range("A1").Value

End Sub

Sub NameSheets()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Sheets
If ws.Range("A1") "" Then
ws.Name = ws.Range("A1").Value
End If
Next ws
End Sub

To install
Copy code as above
Alt+F11 to invoke the Vb Editor
Alt+I+M to Insert a new module
Paste the code into the white pane that appears
Alt+F11 to return to Excel

To Use
Alt+F8
Select the macro to use
Run

--
Regards
Roger Govier

Christine wrote:
Hello all,

I have found a lot of posts about how to populate a cell with the value in
the worksheet tab name, but not the other way around. I would like to
automatically name the worksheet tab based on the value in a specific cell.

I'm ok with formula's but not "up" on VB. Is there a formula I could use to
accomplish this?

Thanks in advance for any help you can give me.

Christine

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


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


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.