+ Reply to Thread
Results 1 to 13 of 13

Automaticaaly Naming Sheets/Tabs from Cell

  1. #1
    Registered User
    Join Date
    12-08-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Automaticaaly Naming Sheets/Tabs from Cell

    Hi,

    Can anyone point me to or let me know the macro used to automatically name a tab/sheet from a specific cell o a different tab/sheet?

    I have been able to find this for cells on the same sheet/tab but not for accessing cells on a different one.

    Thanks in advance

    Warwick

  2. #2
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Automaticaaly Naming Sheets/Tabs from Cell

    try something like

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    12-08-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Automaticaaly Naming Sheets/Tabs from Cell

    Hi,

    Thanks for getting back so quickly, just a quick clarification if I may?

    The code above is placed in the worksheet -> selection change of the sheet whose name I wish to change

    and in thecode I need to replace as follow:

    Sub a()
    Dim x As Long
    For x = 1 To ActiveWorkbook.Sheets.Count
    Sheets(x).Name = Sheets(Sheetname that holds the cell).Rows(rownumber in numeric format).Columns(columnnumber in numeric format)
    Next x
    End Sub

    Thanks Again

  4. #4
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Automaticaaly Naming Sheets/Tabs from Cell

    Hi
    this will change the name of the active sheet whenever the selection changes on the active sheets:

    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Automaticaaly Naming Sheets/Tabs from Cell

    Hi,

    Try this attached workbook and let us know is it for searching .

    Thanks - Naveed.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    12-08-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Automaticaaly Naming Sheets/Tabs from Cell

    Thanks NickyC but I could not get that to work. I placed it in the worksheet->selectchange and used the A1 to insert the sheet name and nothing happened. I am new to this so I am sure it is something I am doing wrong.


    Thanks to you too Naveed, it does change the tab names but I am hoping it may be possible to automate the process.

    I am trying to create a small family tree spreadsheet, where the first sheet is a 4 generation pedigree chart from which I input name birth, marriage and death information. The cell with the persons name is the cell used to automatically name other sheets which will contain more specific individual information

    2012-12-12_10-29_Microsoft Excel.jpg

    As can be seen by the image which I manually set up I am hoping to automate the process so that sheet person1 gets its name from sheet '4 gen Pedigree Chart' cell B15,
    person2 gets its name from sheet '4 gen Pedigree Chart' cell E7, person3 gets its name from sheet '4 gen Pedigree Chart' cell E23, etc etc.

    I hope this makes sense.

    Thanking you in advance

    Warwick

  7. #7
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Automaticaaly Naming Sheets/Tabs from Cell

    Hi

    given the compexity of what you're doing, linking your macro to a sheet change event could get a bit messy. Try using an ordinary macro.
    Without seeing all of your sheet it's a bit hard to come up with a macro for you, but assuming the names you want to use are in columns B, E, H and K, and the names are evenly spaced in your spreadsheet (same number of rows between namesi in each column), something like this should work:


    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    08-30-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    141

    Re: Automaticaaly Naming Sheets/Tabs from Cell

    place this code in thisworkbook and click run

    Please Login or Register  to view this content.
    it will change the sheet name and also cell A1 according to a text or value in cell A2 in Sheet1. If you want to change the name of all sheet, let say 10 sheets, change the i=2 into For i=2 to 10. and below code "Worksheets(i).Range("A1") = Worksheets(i).Name", type Next i.

  9. #9
    Registered User
    Join Date
    12-13-2012
    Location
    Fountain Valley, CA
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Automaticaaly Naming Sheets/Tabs from Cell

    This sounds sort of like something I'm trying to accomplish as well. Although I'm trying to work with data from a master sheet and have it automatically create new tabs based on the A1, A2, or A3 (etc.) value. What I would like to end up with is one tab named per Ax instance as they are updated or created. Any help would be greatly appreciated. And yes, I'm new to excel programming but not to computers.

  10. #10
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Automaticaaly Naming Sheets/Tabs from Cell

    Hi,

    I'd be looking at RootsMagic instead of Excel for this problem. <grin>. I've been working in Access for about a year to do family tree stuff and realize it is a big job. Excel is not relational and fails soon when multiple people are added.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  11. #11
    Registered User
    Join Date
    12-13-2012
    Location
    Fountain Valley, CA
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Automaticaaly Naming Sheets/Tabs from Cell

    Thanks MarvinP. I actually figured it out using:
    Sub AddSheets()
    Dim cell As Excel.Range
    Dim wsWithSheetNames As Excel.Worksheet
    Dim wbToAddSheetsTo As Excel.Workbook

    Set wsWithSheetNames = ActiveSheet
    Set wbToAddSheetsTo = ActiveWorkbook
    For Each cell In wsWithSheetNames.Range("A2:A5")
    With wbToAddSheetsTo
    .Sheets.Add after:=.Sheets(.Sheets.Count)
    On Error Resume Next
    ActiveSheet.Name = cell.Value
    If Err.Number = 1004 Then
    Debug.Print cell.Value & " already used as a sheet name"
    End If
    On Error GoTo 0
    End With
    Next cell
    End Sub
    Last edited by dennis_london; 12-13-2012 at 08:52 PM. Reason: Forgot to mention that I didn't understand how to copy and paste the code into this site and keep the formating.

  12. #12
    Registered User
    Join Date
    12-08-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Automaticaaly Naming Sheets/Tabs from Cell

    Hi all, I think I am starting to think like MarvinP. I might be biting of more than I can chew. Got to start somewhere though.

  13. #13
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Automaticaaly Naming Sheets/Tabs from Cell

    Hey wd,

    If you do travel the Excel path working on this problem I have some suggestions. In one table have individual People. In a second table have the Family Units.

    From the Individual table have two types of pointers to the family table:
    1. Point to the Family where this individual is a Child
    2. Point to the Family(s) where this individual is a Spouse.

    From the Family Table you will need these pointers that point back to the individual table:
    1. Point to the individuals that are Children in this family
    2. Point to the Husband who is in this family (if any)
    3. Point to the Wife who is in this family (if any)

    The above is how GEDCOM works and if you ever wanted to convert to a real genealogical program this would be what you need to work into.
    See:
    http://genealogy.about.com/od/family...ogy-Gedcom.htm and
    http://wiki.phpgedview.net/en/index.php?title=GEDCOM

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1