+ Reply to Thread
Results 1 to 29 of 29

Have the sheet name automatically change in a formula

  1. #1
    Forum Contributor
    Join Date
    10-11-2007
    Location
    St Louis MO
    MS-Off Ver
    365 (v16.53) for Mac
    Posts
    172

    Have the sheet name automatically change in a formula

    I'm new to this, so please don't beat me up too much....

    I am wanting to automatically change the tab names in a formula when I copy the cells down to another row.

    The formula that I'm using is
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    where the sheet name is 01.

    If I add another tab, and name it 56, could that formula automatically change?
    Last edited by CLSSY56; 08-29-2018 at 05:12 PM.
    -Travis
    Mac OS 12.1
    Excel 365 (v16.59)

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Have the sheet name automatically change in a formula

    I don't see how you can say you are new to this when you joined in 2007 and have 95 posts !!

    Is there a column where you can record the sheet names (e.g. column D, starting with D2)? If so, then you can use this formula instead:

    =INDIRECT("'"&D2$"'!C4")

    then copy that down. Note that 01 is a text value, so you will need to set the format of the column that contains the sheet names to Text before you enter those names.

    Hope this helps.

    Pete

  3. #3
    Forum Contributor
    Join Date
    10-11-2007
    Location
    St Louis MO
    MS-Off Ver
    365 (v16.53) for Mac
    Posts
    172

    Re: Have the sheet name automatically change in a formula

    I ask a lot of questions trying to understand excel, hopefully one day I may return the favor.

    I'll give that a shot to see if that does what I want to do.

    So out of that of which you posted, what can I copy and paste into different similar formulas?

  4. #4
    Forum Contributor
    Join Date
    10-11-2007
    Location
    St Louis MO
    MS-Off Ver
    365 (v16.53) for Mac
    Posts
    172

    Re: Have the sheet name automatically change in a formula

    I get this error...
    Screen Shot 2018-08-29 at 9.35.22 AM.png

    The formula I used was this:
    =INDIRECT("'"&A4$"'!C4")

  5. #5
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Have the sheet name automatically change in a formula

    Quote Originally Posted by CLSSY56 View Post
    ... So out of that of which you posted, what can I copy and paste into different similar formulas? ...
    The formula is shown on the third line of my answer - it begins with an = sign. When you put this in a cell on row 2 and then copy it down, the D2 part will change to D3, D4, D5 etc. on successive rows, and so it will pick up the sheet name from those cells and return the value from C4 on that sheet. The C4 will not change when it is copied down, because it is treated as text.

    I do not know why you get that error message as I can't see what you have been trying, so if you can't resolve it yourself it would help if you attached a sample Excel workbook.

    To do this, click on Go Advanced (below the Edit Window) while you are composing a reply, then scroll down to and click on Manage Attachments and the Upload window will open. Click on Browse and navigate to (and double-click) the file icon that you want to attach, then click on Upload and then on Close this Window to return to the Edit window. When you have finished composing your post, click on Submit Post. Don't try to use the Paperclip icon, as it doesn't work on this forum.

    Hope this helps.

    Pete

  6. #6
    Forum Contributor
    Join Date
    10-11-2007
    Location
    St Louis MO
    MS-Off Ver
    365 (v16.53) for Mac
    Posts
    172

    Re: Have the sheet name automatically change in a formula

    I assume this is the important part of the formula is in RED

    =INDIRECT("'"&A4$"'$C$4")
    Last edited by CLSSY56; 08-29-2018 at 10:51 AM.

  7. #7
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Have the sheet name automatically change in a formula

    Sorry, I mis-typed a symbol, and you have changed the ! to ' (and added another ") - try this:

    =INDIRECT("'" & A4 & "'!C4")

    Hope this helps.

    Pete
    Last edited by Pete_UK; 08-29-2018 at 10:55 AM.

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,998

    Re: Have the sheet name automatically change in a formula

    The red highlighted parts below should just be an ampersand and exclamation mark:

    =INDIRECT("'"&A4$"'"'$C$4")

    so it reads:

    =INDIRECT("'"&A4[B]&"'!$C$4")
    Last edited by romperstomper; 08-29-2018 at 10:54 AM.
    Everyone who confuses correlation and causation ends up dead.

  9. #9
    Forum Contributor
    Join Date
    10-11-2007
    Location
    St Louis MO
    MS-Off Ver
    365 (v16.53) for Mac
    Posts
    172

    Re: Have the sheet name automatically change in a formula

    =INDIRECT("'"&A4&"'!$C$4")

    That worked, cell wouldn't take the 0 in 01, so the formula did't work until I changed the tab to 10

    Now to figure out what all that means and apply it to other formulas....

  10. #10
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Have the sheet name automatically change in a formula

    Glad to hear that you got it working.

    If that takes care of your original question, please take a moment to select Thread Tools from the menu above and to the right of your first post and mark this thread as SOLVED.

    Also, since you are relatively "new" to the forum, you might like to know that you can directly thank those who have helped you by clicking on the small "star" icon located in the lower left corner of a post that you have found to be helpful (not just in this thread - for any post that has helped you). This also adds to the reputation of the poster (the small green bars in the poster's profile).

    Pete

  11. #11
    Forum Contributor
    Join Date
    10-11-2007
    Location
    St Louis MO
    MS-Off Ver
    365 (v16.53) for Mac
    Posts
    172

    Re: Have the sheet name automatically change in a formula

    How do I get this to work ='10'!$F$6>'10'!$F$7 as stated above, for a Conditional Format?

    =INDIRECT("'"&A4&"'!$F$6)>INDIRECT("'"&A4&"'!$F$7) didn't work

    neither did this =INDIRECT("'"&A4&"'!$F$6)>("'"&A4&"'!$F$7)
    Last edited by CLSSY56; 08-29-2018 at 11:28 AM.

  12. #12
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Have the sheet name automatically change in a formula

    In all cases quoted above (Post #11) you have omitted the final quotes inside the closed bracket, so the expressions are not valid.

    In the final example, you would have to use INDIRECT twice, once for each cell reference (as per the line above).

    Your profile does not state which version of Excel you are using, but in earlier versions (up to XL2010, I think, or maybe even XL2013) conditional formatting did not allow you to directly reference other worksheets, so you won't be able to do it that way, anyway. You can put the (valid) expression in a cell on the same worksheet and reference that instead in your CF condition.

    Hope this helps.

    Pete

  13. #13
    Forum Contributor
    Join Date
    10-11-2007
    Location
    St Louis MO
    MS-Off Ver
    365 (v16.53) for Mac
    Posts
    172

    Re: Have the sheet name automatically change in a formula

    Did you mean like this?
    =INDIRECT("'"&A4&"'"!$F$6)>INDIRECT("'"&A4&"'"!$F$7)

    I must have something wrong, as that didn't work either.

  14. #14
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Have the sheet name automatically change in a formula

    No, like this:

    =INDIRECT("'"&A4&"'!$F$6")>INDIRECT("'"&A4&"'!$F$7")

    I have removed the quote after the second apostrophe and put it just inside the close bracket.

    Hope this helps.

    Pete

  15. #15
    Forum Contributor
    Join Date
    10-11-2007
    Location
    St Louis MO
    MS-Off Ver
    365 (v16.53) for Mac
    Posts
    172

    Re: Have the sheet name automatically change in a formula

    ok so I understand this better...

    ='10'!$F$6>'10'!$F$7

    =INDIRECT("'"&A4&"'!$F$6")>INDIRECT("'"&A4&"'!$F$7")

  16. #16
    Forum Contributor
    Join Date
    10-11-2007
    Location
    St Louis MO
    MS-Off Ver
    365 (v16.53) for Mac
    Posts
    172

    Re: Have the sheet name automatically change in a formula

    ok that kinda worked, when I copy it down "&A4&" doesn't change, it stays at A4.

  17. #17
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Have the sheet name automatically change in a formula

    That's right. You are building up a string of text which is made up of three parts, so you have:

    "'"
    &
    A4
    &
    "'!$F$6"

    and if A4 contains 10, then the composite string would be:

    "'10'!$F$6"

    However, this is just a piece of text to Excel, so to turn it into a valid cell reference you need to put it inside the INDIRECT( … ) function.

    Hope this helps.

    Pete

  18. #18
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Have the sheet name automatically change in a formula

    Quote Originally Posted by CLSSY56 View Post
    ok that kinda worked, when I copy it down "&A4&" doesn't change, it stays at A4.
    Two things to check - Is your calculation mode set to Manual, rather than Automatic, OR is the cell formatted as Text instead of General?

    Pete

  19. #19
    Forum Contributor
    Join Date
    10-11-2007
    Location
    St Louis MO
    MS-Off Ver
    365 (v16.53) for Mac
    Posts
    172

    Re: Have the sheet name automatically change in a formula

    Where do I find that out at?

  20. #20
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Have the sheet name automatically change in a formula

    On the Formulas tab at the top of the sheet, you should find the Calculation Options towards the right, in the Calculation group - just check on Automatic if it is set to Manual. Or, just press the F9 key to force a recalculation.

    To check the formatting of the cell, right-click then choose Format Cells and on the Number tab you want the Category to be set as General. Then click in the formula bar (or press the F2 key) as if to edit the cell, then press < Enter > to effect the change.

    I see that you have now set up a signature to say that you are using a Mac - I don't know if these directions will be exactly the same on a Mac compared with a PC.

    Hope this helps.

    Pete

  21. #21
    Forum Contributor
    Join Date
    10-11-2007
    Location
    St Louis MO
    MS-Off Ver
    365 (v16.53) for Mac
    Posts
    172

    Re: Have the sheet name automatically change in a formula

    It's very close to the PC version... just back a few years from what I understand.

    Calculation Option is Automatic
    Cell Format is General

    The CF did work as the first formula I had, just not the one you posted, cells won't turn red like they are suppose to
    Last edited by CLSSY56; 08-29-2018 at 12:29 PM.

  22. #22
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Have the sheet name automatically change in a formula

    Tell me again what formula you are using, or alternatively attach your workbook, as detailed in Post #5.

    Pete

  23. #23
    Forum Contributor
    Join Date
    10-11-2007
    Location
    St Louis MO
    MS-Off Ver
    365 (v16.53) for Mac
    Posts
    172

    Re: Have the sheet name automatically change in a formula

    Let me know if you can open this file.
    Attached Files Attached Files

  24. #24
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Have the sheet name automatically change in a formula

    I opened the file and it seems to be working fine - this is what shows in cells A4:A6:

    10 .... 1980 .... Mazda .... RX-7 ........... 50000
    11 .... 1987 .... Jeep ...... Comanche .... 45000
    12 .... 1992 .... Ford ...... Probe ........... 31000

    (I've manually added the full-stops to try to keep the column data aligned).

    Below that block you have a lot of #REF errors, because those sheets have not yet been added. You can overcome the errors by using this in A4:

    =IFERROR(INDIRECT("'"&A4&"'!$C$4"),"")

    and this will show blanks instead when it is copied down.

    I'm not sure what problem you are having, then.

    Pete

  25. #25
    Forum Contributor
    Join Date
    10-11-2007
    Location
    St Louis MO
    MS-Off Ver
    365 (v16.53) for Mac
    Posts
    172

    Re: Have the sheet name automatically change in a formula

    On the Master List tab, vehicle 10-12 should be red because of the milage, just like on the individual tabs.

  26. #26
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Have the sheet name automatically change in a formula

    Put this formula in F4 of the Master sheet:

    =IFERROR(INDIRECT("'"&A4&"'!$F$6")>INDIRECT("'"&A4&"'!$F$7"),"")

    and copy down. It is based on the CF formula that you are trying to use and returns TRUE, FALSE or blank, as appropriate.

    Then select cell E4 and click on Conditional Formatting | Manage rules, and change the Applies to box to =$B$4:$E$100

    Then click on Edit Rule and change your condition to just:

    =$F4

    (Note there is no $ symbol in front of the 4).

    That should work for you.

    Hope this helps.

    Pete

  27. #27
    Forum Contributor
    Join Date
    10-11-2007
    Location
    St Louis MO
    MS-Off Ver
    365 (v16.53) for Mac
    Posts
    172

    Re: Have the sheet name automatically change in a formula

    Thanks for all your help Pete!

  28. #28
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Have the sheet name automatically change in a formula

    Glad to help - thanks for the rep.

    Pete

  29. #29
    Forum Contributor
    Join Date
    10-11-2007
    Location
    St Louis MO
    MS-Off Ver
    365 (v16.53) for Mac
    Posts
    172

    Re: Have the sheet name automatically change in a formula

    Pete, I have a another that I need help with...

    When copying a tab:
    • Is there a way for the cell F6 to use the truck number in C3 and reference it to get the milage from the "Master List" and display the milage?
    It would be kinda like this =IF($A21>0,VLOOKUP($A21,'[Est Tables_2018.xlsx]Est Tables'!$A$6:$D$65503,3,0),"") but not referencing another file, only a tab?

    I tried the formula below, which that gave me #N/A, so I know I don't have something right.
    =IF($C3>0,VLOOKUP($C3,'Master List'!$A$4:$E$65503,3,0),"")
    Last edited by CLSSY56; 09-12-2018 at 10:04 AM.

+ 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. How can I change sheet tab name automatically?
    By sudbhavani in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 05-12-2017, 10:07 AM
  2. Replies: 2
    Last Post: 01-01-2015, 09:38 PM
  3. [SOLVED] Automatically change sheet number when first sheet is filled in.
    By Bikeman in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-29-2014, 04:36 PM
  4. change data automatically from one sheet to another
    By stoey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-01-2011, 03:39 PM
  5. Automatically Change Sheet Tab Name With Date in Cell
    By chrisneu in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-31-2011, 11:34 PM
  6. Replies: 2
    Last Post: 11-23-2005, 08:18 PM
  7. Automatically run macro on sheet change
    By Steven in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-17-2005, 07:21 PM

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