#1
|
|||
|
|||
Auto rename tab
Anyone have a clue how to automatically rename sheet tabs to a name in a cell in another tab?
So, if sheet 1 in A2 has the Value "OAC-125" then the following tab names would be updated with that name as follows: Sheet 2 - Current Name: DAR Updated to: OAC-125 DAR Sheet 3 - Current Name: ZKL Updated to: OAC-125 ZKL you get it ha? I thought maybe some formula can be entered with the concatenate symbol in each tab like this: Sheet 2 - Sheet 1! A2 & DAR Any idea guys/gals? thank.s |
#2
|
||||
|
||||
A formula cannot change a sheet's name. At the very least, a macro would be required.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
||||
|
||||
Check whether this event code fulfills your expectation
To Add Excel VBA Code to a Workbook / This Workbook Module
Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object) Dim sWs As String, sCell As String sWs = UCase(Sh.Name) sCell = UCase(Sh.Range("A2").Value) If Trim(sCell) <> "" Then If Left(sWs, Len(sCell)) <> sCell Then On Error Resume Next Sh.Name = sCell & " " & sWs On Error GoTo 0 End If End If End Sub |
#4
|
|||
|
|||
Hi Sixthsense,
The code works great! Thank you. However, how can I tweak it so that all four tabs are renamed at exactly the moment the text is entered in the first tab in cell D9? So, this would be a change event related to that cell? The tabs would not have the same name as the text entered in cell D9 since the value entered in cell D9 would be appended as the prefix with a space between to the existing tab names like this: D9 = OAC Tab 1 = 123 becomes OAC 123 Tab 2 = 789 becomes OAC 789 Tab 3 = 456 becomes OAC 456 Thanks |
#5
|
|||
|
|||
Solved;
With Sixthsense' help from above and some tweaking of my own I have solved the riddle.
Thus, any time cell D9 has an entry made to it whether adding in an entry or deleting an entry the tabs will update. When adding an entry the tabs will have the entry added as a prefix to the already existing tab name with a space between the newly added prefix and existing tab name. Also, when the entry in cell D9 is deleted, the tabs will revert back to their original tab names with the prefix being removed. Pretty cool ha? Here is the code which needs to be added to the sheet object where cell D9 will be updated in project explorer. Quote:
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to Rename a Quick Part | sleake | Word | 14 | 10-14-2013 09:21 AM |
Variable to rename a tab in a worksheet via VBA | Chayes | Excel Programming | 5 | 08-07-2012 02:03 AM |
Rename Files | gsrikanth | Excel Programming | 3 | 05-14-2012 03:03 AM |
Can't rename shared calendars | kenelder | Outlook | 0 | 06-02-2011 07:53 AM |
Rename File | cksm4 | Word VBA | 2 | 02-25-2011 09:29 AM |