+ Reply to Thread
Results 1 to 12 of 12

INDEX() doesn't work with MID() and CELL() to list names of sheets

  1. #1
    Forum Contributor
    Join Date
    05-20-2017
    Location
    Boston, US
    MS-Off Ver
    Mac 2011
    Posts
    139

    INDEX() doesn't work with MID() and CELL() to list names of sheets

    Hello!

    Please, take a look at the attached file. I am trying to post names of all sheets in the workbook by using INDEX(), MID() and CELL() functions.

    MID() and CELL() work beautifully when not used within the INDEX() function.

    Please, help me to understand my mistake.
    Thank you very much!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,188

    Re: INDEX() doesn't work with MID() and CELL() to list names of sheets

    You need the CELL function in each Sheet: VBA may be a better solution.

  3. #3
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: INDEX() doesn't work with MID() and CELL() to list names of sheets

    read here: INDEX()

  4. #4
    Forum Contributor
    Join Date
    05-20-2017
    Location
    Boston, US
    MS-Off Ver
    Mac 2011
    Posts
    139

    Re: INDEX() doesn't work with MID() and CELL() to list names of sheets

    Quote Originally Posted by JohnTopley View Post
    You need the CELL function in each Sheet: VBA may be a better solution.
    I see. Thank you!

  5. #5
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: INDEX() doesn't work with MID() and CELL() to list names of sheets

    This macro will list all sheet names:
    Please Login or Register  to view this content.
    Regards,
    Aardigspook

    I recently started a new job so am a bit busy and may not reply quickly. Sorry - it's not personal - I will reply eventually.
    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark this Thread as Solved'.
    If you use commas as your decimal separator (1,23 instead of 1.23) then please replace commas with semi-colons in your formulae.
    You don't need to give me rep if I helped, but a thank-you is nice.

  6. #6
    Forum Contributor
    Join Date
    05-20-2017
    Location
    Boston, US
    MS-Off Ver
    Mac 2011
    Posts
    139

    Re: INDEX() doesn't work with MID() and CELL() to list names of sheets

    Quote Originally Posted by Aardigspook View Post
    This macro will list all sheet names:
    Please Login or Register  to view this content.
    Thank you very much. It sounds really promising, but, to be honest, I don't know yet how to use macros, how and where to type this code.

  7. #7
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: INDEX() doesn't work with MID() and CELL() to list names of sheets

    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button


    ^ Those are the instructions for Windows - I don't use Mac, so don't know if you have exactly the same (the 'Alt' key for example) - but hopefully that's enough to help. If not, please get back to us.
    Last edited by Aardigspook; 06-23-2017 at 08:45 AM.

  8. #8
    Forum Contributor
    Join Date
    05-20-2017
    Location
    Boston, US
    MS-Off Ver
    Mac 2011
    Posts
    139

    Re: INDEX() doesn't work with MID() and CELL() to list names of sheets

    Quote Originally Posted by Aardigspook View Post
    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button


    ^ Those are the instructions for Windows - I don't use Mac, so don't know if you have exactly the same (the 'Alt' key for example) - but hopefully that's enough to help. If not, please get back to us.
    Thank you very much for your help. I tried this, but, honestly, I need to learn a lot about VBAs before trying to use it.

    EDIT: gave it another shot. I worked. But:

    - it put the list in column 1 and cells starting from the second; not where I need it; so I decided to try and change the code;

    when I put the 4 in Columns(1).Insert , that obviously inserted a new 4th column, which I didn't need; so I changed the code back;
    then I decided to try to start the list not from i = 1, but from i = 33 (I need the list to start at D33), that did add a new column, but an empty one, with no list at all;

    - I also miss a hyperlinks.

    Is it possible to correct the macro in such way that these issues are addressed?
    I have read that the approach I use with GET.WORKBOOK is not safe, so it would great to learn how to set a correct macro (or macros).
    Thank you very much!
    Last edited by Vitalite; 06-26-2017 at 05:40 AM. Reason: added additional information

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: INDEX() doesn't work with MID() and CELL() to list names of sheets

    Another way using a UDF (User Defined Function)...

    Create a range name (I called mine Sheetnanes
    In the Refers To: =REPLACE(GET.WORKBOOK(1),1,FIND("]",GET.WORKBOOK(1)),"")

    To get a list of sheet names, put this in a cell and copy down (started in A2)...
    =IFERROR(INDEX(Sheetnames,ROWS($A$2:A2)),"")

    If you want to be able to click the cell and go to that worksheet, change that formula to this...
    =IFERROR(HYPERLINK("#"&"'"&INDEX(Sheetnames,ROWS($A$2:A2))&"'!A1",INDEX(Sheetnames,ROWS($A$2:A2))),"")
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  10. #10
    Forum Contributor
    Join Date
    05-20-2017
    Location
    Boston, US
    MS-Off Ver
    Mac 2011
    Posts
    139

    Re: INDEX() doesn't work with MID() and CELL() to list names of sheets

    Quote Originally Posted by FDibbins View Post
    Another way using a UDF (User Defined Function)...

    Create a range name (I called mine Sheetnanes
    In the Refers To: =REPLACE(GET.WORKBOOK(1),1,FIND("]",GET.WORKBOOK(1)),"")

    To get a list of sheet names, put this in a cell and copy down (started in A2)...
    =IFERROR(INDEX(Sheetnames,ROWS($A$2:A2)),"")

    If you want to be able to click the cell and go to that worksheet, change that formula to this...
    =IFERROR(HYPERLINK("#"&"'"&INDEX(Sheetnames,ROWS($A$2:A2))&"'!A1",INDEX(Sheetnames,ROWS($A$2:A2))),"")
    Thank you very much! I have a post about the problem with creating Hyperlinks if I use the same approach you suggested.
    Could you, please, explain to me how your hyperlink formula works, and also why the formula I found elsewhere doesn't? Does the first "#" stand for the name of the workbook?

    I also have a question on why in both cases the INDEX formula is used twice within the hyperlink formula.

    Here is the link to my previous post:
    https://www.excelforum.com/excel-new...ml#post4683105

    Here is the formula I asked about there:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by Vitalite; 06-26-2017 at 03:27 AM.

  11. #11
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: INDEX() doesn't work with MID() and CELL() to list names of sheets

    HYPERLINK has 2 parts - the 1st part creates the link, the 2nd part names it, so I used 2 INDEX's, firstly to create the link, and then to name the link based on what the link actually is.

    As far as trouble-shooting that other formula - hard to say without seeing it in context

  12. #12
    Forum Contributor
    Join Date
    05-20-2017
    Location
    Boston, US
    MS-Off Ver
    Mac 2011
    Posts
    139

    Re: INDEX() doesn't work with MID() and CELL() to list names of sheets

    Quote Originally Posted by FDibbins View Post
    HYPERLINK has 2 parts - the 1st part creates the link, the 2nd part names it, so I used 2 INDEX's, firstly to create the link, and then to name the link based on what the link actually is.

    As far as trouble-shooting that other formula - hard to say without seeing it in context
    I see now. I couldn't understand why we use INDEX twice. Now I understand that the second one creates a name. Thank you very much!
    As to the another formula, I have provided a context, including the file, in my another thread, which I linked here. But! I have solved the problem thanks to your formula - I have found a few mistakes in that formula.

    If by any chance you have time, could you, please, take a look at that 'old', but now corrected, formula. I still don't understand the role of one digit in it. When I use your formula, though a bit modified with the MID to get only the name of the sheet, I don't use that one digit, and it works fine. But, digit or not, both formulas work; so what does that digit do?

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Here is the digit I am talking about - it's the last one in the INDEX part:
    INDEX(MID(excel_qns,FIND("]",excel_qns)+1,255),ROWS(A$1:A1),1)


    And here is how I modified your formula - now it return only the name of the sheet.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Does the "#" in (HYPERLINK("#" ... mean the name of the workbook?

    Thank you very much!
    Last edited by Vitalite; 06-26-2017 at 04:02 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. Match Index Doesn't Work
    By benjie1984 in forum Excel General
    Replies: 3
    Last Post: 03-02-2017, 04:32 PM
  2. Index formula doesn't work
    By ioncila in forum Excel General
    Replies: 2
    Last Post: 11-17-2015, 12:07 PM
  3. [SOLVED] Index exact match doesn't work
    By I.am.Rustam in forum Excel General
    Replies: 2
    Last Post: 11-11-2015, 11:55 PM
  4. Macro to delete range names doesn't work??
    By Merf in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-26-2015, 10:35 PM
  5. Index + Match doesn't work with text
    By blueturnaround in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-19-2014, 01:18 PM
  6. Digital signature doesn't work in a workbook with formula's in names.
    By MichaelHd in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-11-2014, 11:13 AM
  7. Index Match Match Formula DOESN'T WORK WITH TABLES/TABLE NAMES ??
    By Underling in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-04-2014, 09:01 PM

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