+ Reply to Thread
Results 1 to 19 of 19

Automatically increment worksheet numbers

  1. #1
    Registered User
    Join Date
    06-09-2009
    Location
    -
    MS-Off Ver
    Excel 2003
    Posts
    11

    Automatically increment worksheet numbers

    Hi All,

    In my workbook I have a summary sheet and then will have approx 200 tabs (worksheets) after the summary sheet. Of those 200 tabs each tab is exactly the same and i need to pull the exact same data from each and every tab into the summary sheet.

    Can someone please advise me on how to automatically increase the tab number by one?

    e.g. My tab numbers will be 01 through to 200. I am currently using as a formula: ='01'!$L$6

    Obviously pointing to Tab 01 and in that tab Cell L6..

    i need this to automatically change when i drag the cell down to:
    ='01'!$L$6
    ='02'!$L$6
    ='03'!$L$6
    ='04'!$L$6
    ..
    ='200'!$L$6 ... and so on.

    Thanks in advance all, much appreciated.

  2. #2
    Registered User
    Join Date
    06-01-2009
    Location
    India
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    66

    Thumbs up Re: Automatically increment worksheet numbers

    Here is the formula:

    Please Login or Register  to view this content.
    Just take care of the following couple of things before you use the code;
    • Replace H17 and $H$17 with the cell address where you want to copy this function and do not replace anything else. So, for example the first cell in which you want to put this function is A1, then H17 should be replaced with A1 and $H$17 should be replaced with A1 and $A$1, respectively. Then simply drag down the formula and it will be done
    • This code will work for till sheet numbers less than 10,000.

    In case you face any issues using this, just PM with the link to this thread.
    Mohit Khurana, CFA

    Excel Matic - A blog on MS Excel

    List of Essential Excel Shortcuts

    e-Book on Excel Math Functions

    Please add to our reputation if you find our replies as helpful.

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Automatically increment worksheet numbers

    I would propose:

    ="'"&TEXT(ROWS(A$1:A1),"00")&"'!L6"
    copy down

    To execute the above you have 2 options

    1: adjust the above text string to incorporate an "=" and copy/paste values the results over the original formulae then run Edit -> Replace, Replacing = with = (coerces the strings to formulae)

    2: use INDIRECT

    =INDIRECT("'"&TEXT(ROWS(A$1:A1),"00")&"'!L6")
    copy down

    NOTE: INDIRECT is Volatile so should be avoided if used in large quantities

  4. #4
    Registered User
    Join Date
    06-01-2009
    Location
    India
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    66

    Thumbs up Re: Automatically increment worksheet numbers

    Hi DonkeyOte,

    Your first option is really great!!

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Automatically increment worksheet numbers

    Quote Originally Posted by Excel Matic View Post
    In case you face any issues using this, just PM with the link to this thread.
    All questions pertaining to a thread should be made within the thread, not privately.

    sdaddy, if you have questions please ensure you post them here directly.

    Thanks

  6. #6
    Registered User
    Join Date
    06-01-2009
    Location
    India
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    66

    Thumbs up Re: Automatically increment worksheet numbers

    DonkeyOte -

    I never asked anyone to ask me questions through PM. I only asked him to send me the link to this thread to me so that I can be reminded of this thread.

    I have read all the rules and I respect them.

    Hope it is clear now!

  7. #7
    Registered User
    Join Date
    06-09-2009
    Location
    -
    MS-Off Ver
    Excel 2003
    Posts
    11

    Question Re: Automatically increment worksheet numbers

    Thanks for your help DonkeyOte. I have stuck with the Indirect function, i understand the volatility and hopefully i dont end up having to use too large quantities of worksheets.

    One further question i have is that after using...

    =INDIRECT("'"&TEXT(ROWS(A$1:A1),"00")&"'!H7")

    Note: i have changed it for cell H7. H7 is a field which checks two cells E21 and E22 in sheet '01' and outputs the field that displays text in it...

    =IF(ISBLANK('01'!E21),IF(ISBLANK('01'!E22),"",'01'!E22),'01'!E21)

    how would i then be able to incorporate the indirect formula to populate my if(isblank) statements? i have a couple of them...

    i tried using...

    =INDIRECT("'"&TEXT(ROWS(A$1:A1),"00")&IF(ISBLANK('01'!E21),IF(ISBLANK('01'!E22),"",'01'!E22),'01'!E21)))

    with no luck...

    Thanks again.

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Automatically increment worksheet numbers

    I offered a slight variation to your other thread:

    http://www.excelforum.com/excel-gene...one-value.html

    If the values present in the cells are you could go for:

    Please Login or Register  to view this content.

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Automatically increment worksheet numbers

    Excel matic - code tags are for posting code, not formulae!
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Automatically increment worksheet numbers

    hi Roy, I believe the issue of spurious spaces still persists post server move if you try to post long formulae less code tags... (see sdaddy's last formulae in their last post)

  11. #11
    Registered User
    Join Date
    06-09-2009
    Location
    -
    MS-Off Ver
    Excel 2003
    Posts
    11

    Exclamation Re: Automatically increment worksheet numbers

    Hi Donkey Ote,
    I tried using ure given formula...

    =TRIM(REPT(INDIRECT("'"&TEXT(ROWS(A$1:A1),"00")&"'!E21")&" "&INDIRECT("'"&TEXT(ROWS(A$1:A1),"00")&"'!E22"),1))

    However, if both text fields (E21 and E22) are filled in the cell displays both values. How can i cut out redundant data and stop any repetition for occuring?

    Help much appreciated.

  12. #12
    Valued Forum Contributor
    Join Date
    11-11-2008
    Location
    Euro
    MS-Off Ver
    2007, 2010
    Posts
    470

    Re: Automatically increment worksheet numbers

    try to the following formula:
    PHP Code: 
    =IF(ISBLANK(INDIRECT("'"&TEXT(ROWS(A$1:A1),"00")&"'!E21")),IF(ISBLANK(INDIRECT("'"&TEXT(ROWS(A$1:A1),"00")&"'!E22")),"",INDIRECT("'"&TEXT(ROWS(A$1:A1),"00")&"'!E22")),INDIRECT("'"&TEXT(ROWS(A$1:A1),"00")&"'!E21")) 
    Last edited by tigertiger; 06-12-2009 at 07:46 PM.

  13. #13
    Valued Forum Contributor
    Join Date
    11-11-2008
    Location
    Euro
    MS-Off Ver
    2007, 2010
    Posts
    470

    Re: Automatically increment worksheet numbers

    Because there is no space in the name sheets created in TEXT(ROWS(A$1:A1),"00"), we should use the shorter formula:

    PHP Code: 
    =IF(ISBLANK(INDIRECT(TEXT(ROWS(A$1:A1),"00")&"!E21")),IF(ISBLANK(INDIRECT(TEXT(ROWS(A$1:A1),"00")&"!E22")),"",INDIRECT(TEXT(ROWS(A$1:A1),"00")&"!E22")),INDIRECT(TEXT(ROWS(A$1:A1),"00")&"!E21")) 
    Do you think so?


    OR, with the next formula (may include SPACE):
    PHP Code: 
    =IF(ISBLANK(INDIRECT(TEXT(ROWS(A$1:A1),"'00")&"'!E21")),IF(ISBLANK(INDIRECT(TEXT(ROWS(A$1:A1),"'00")&"'!E22")),"",INDIRECT(TEXT(ROWS(A$1:A1),"'00")&"'!E22")),INDIRECT(TEXT(ROWS(A$1:A1),"'00")&"'!E21")) 
    .
    Last edited by tigertiger; 06-09-2009 at 08:26 PM. Reason: more information

  14. #14
    Registered User
    Join Date
    06-09-2009
    Location
    -
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Automatically increment worksheet numbers

    Thanks everyone for the help. Much appreciated. This workbook issue is now complete. Tigertiger i used your shorter formula and agreed it works correctly.

  15. #15
    Valued Forum Contributor
    Join Date
    11-11-2008
    Location
    Euro
    MS-Off Ver
    2007, 2010
    Posts
    470

    Re: Automatically increment worksheet numbers

    OR another option

    PHP Code: 
    =IF(ISBLANK(INDIRECT(TEXT(ROWS($1:1),"'00")&"'!E21")),IF(ISBLANK(INDIRECT(TEXT(ROWS($1:1),"'00")&"'!E22")),"",INDIRECT(TEXT(ROWS($1:1),"'00")&"'!E22")),INDIRECT(TEXT(ROWS($1:1),"'00")&"'!E21")) 
    now,
    + shorter
    + and you can delete column A that doesn't effect the result
    .
    Last edited by tigertiger; 06-12-2009 at 07:46 PM.

  16. #16
    Registered User
    Join Date
    11-29-2012
    Location
    Dublin
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Automatically increment worksheet numbers

    Hi

    I have found this thread to be a potential solution to a similar problem only I cant seem to get it to work correctly.

    Could someone please point me in the wright direction.

    I have data in worksheets that make up the 52 weeks of the year. Each sheet is numbered like this "WK1" "WK2" and so on... up to "WK52"

    Each sheet is setup exactly the same so all cells are the same.

    So I have a summary sheet that structures the data from all the week sheets to plot to graph all within the same file.

    Thing is when I link the first cell to the first sheet say WK1 and then try to drag the formula down to the worksheet number does not increment

    Tried the code in the beginning of this post and it displays the worksheet and cell number in the cell cant get the actual data to be displayed.

    When I drag this formula down I want it to index the worksheet number

    =WK44!$AG$14

    Like this

    =WK44!$AG$14
    =WK45!$AG$14
    =WK46!$AG$14

    This is what I get in the cell when I use the formula given in the post

    WK01! $AG$14



    Any help on this would be greatly appreciated.

  17. #17
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Automatically increment worksheet numbers

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  18. #18
    Registered User
    Join Date
    11-18-2015
    Location
    Binan, Laguna, Philippines
    MS-Off Ver
    2013
    Posts
    1

    Re: Automatically increment worksheet numbers

    Referencing C20.png

    I am having trouble referencing C20. Any comments on this?

    Thanks in advance.

  19. #19
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,127

    Re: Automatically increment worksheet numbers

    Hi. welcome to the forum.

    Please don't open an old thread. It will most likely be ignored. Start a new one.

    Explain more clearly what your problem is. Also, since you have attached a picture, we really can't tell what you are trying to do. So... please attach a sample workbook. Make sure there is enough data to demonstrate your need. Make sure your desired results are shown, mock them up manually if necessary. Remember to remove ALL confidential information first!!!

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    The paperclip icon
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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