+ Reply to Thread
Results 1 to 6 of 6

Renaming sheet based on sheet where "new sheet" code originated from

  1. #1
    Registered User
    Join Date
    01-28-2016
    Location
    Western Austalia
    MS-Off Ver
    2010
    Posts
    36

    Renaming sheet based on sheet where "new sheet" code originated from

    Hi there

    "VERY" new to VB coding, in Excel but trying to do the following:

    Initial Workbook set up with 3 worksheets:
    1. Menu sheet with project start buttons
    2 First template sheet - DataTable sheet
    3. Second template sheet - Graph sheet

    Now, the sequence is:

    1. Button on menu sheet creates a copy of a datatable spreadsheet (sheet #2) for the user to fill in - will prompt user to rename via messagebox - all ok
    2. Button on new DataTable sheet (which has been renamed by user) will then ask to generate a copy the Graph Sheet (sheet #3) once data has been entered.

    No problem generating a copy of the GraphTable sheet, but want to rename this automatically to whatever name the user has given to the DataTable sheet, followed by '-Graph'

    As the DataTable sheet is not a constant sheet (user can create multiple DataSheets for various uses and rename them, so even sheetcodename is not known in advance.)

    So how would I be able to have the GraphTable renamed automatically at time of copying the graph template in this case?

    I know that adding & "-Graph" behind the ActiveSheet.Name once the sheet has been copied will add the extension, but no clue as to how to grab the initial TableData sheet name which had the button that was pressed to create this new sheet.

    User can create DataTable Sheet and subsequent Graph sheets as many times as required for different data, so wanted to make sure that it was obvious which graph sheet belonged to which datatable sheet by having the same name followed by '-graph'

    Assistance appreciated!

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Renaming sheet based on sheet where "new sheet" code originated from

    ActiveSheet.name will give you the name for the sheet on which the button is pressed

  3. #3
    Registered User
    Join Date
    01-28-2016
    Location
    Western Austalia
    MS-Off Ver
    2010
    Posts
    36

    Re: Renaming sheet based on sheet where "new sheet" code originated from

    Quote Originally Posted by Kyle123 View Post
    ActiveSheet.name will give you the name for the sheet on which the button is pressed
    I thought this would be the case as well, but have already tried this a couple of days ago.

    In my case it gives the name of the Graph Sheet template that has been generated by pressing the button on the Table sheet -- that is my problem. What I want it to do is to get the name of the Table Sheet (where the button is located),then name the newly generated template sheet with that name followed by -Graph...

  4. #4
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Renaming sheet based on sheet where "new sheet" code originated from

    Use a variable to store the initial sheet name...
    Please Login or Register  to view this content.
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

  5. #5
    Registered User
    Join Date
    01-28-2016
    Location
    Western Austalia
    MS-Off Ver
    2010
    Posts
    36

    Re: Renaming sheet based on sheet where "new sheet" code originated from

    Quote Originally Posted by bulina2k View Post
    Use a variable to store the initial sheet name...
    THank you! I failed to declare the original sheet name value BEFORE adding the new sheet! Working now!

  6. #6
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Renaming sheet based on sheet where "new sheet" code originated from

    Glad to help. Thank you for the rep point.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copying all Datas in another sheet based if "Order Received" Synchonized in other sheet
    By Heide Rayos in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-01-2014, 01:44 PM
  2. [SOLVED] Code that copies row of data to another sheet based on text "Complete"/"Delete"
    By Dremzy in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 04-20-2014, 05:51 PM
  3. Replies: 2
    Last Post: 04-20-2014, 11:18 AM
  4. Replies: 3
    Last Post: 05-31-2013, 05:16 AM
  5. Extract list from sheet "A" to sheet "B# based on certain criteria
    By lysaar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-19-2013, 01:58 PM
  6. Auto-renaming a sheet from a "main" sheet
    By ammauric in forum Excel General
    Replies: 0
    Last Post: 04-13-2011, 09:18 AM
  7. Prevent code in "Sheet Activate" from running when sheet made visible from other macr
    By Simon Lloyd in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-21-2006, 04:15 AM

Tags for this Thread

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