+ Reply to Thread
Results 1 to 31 of 31

Get a list of worksheets that works in web and desktop without VBA

  1. #1
    Registered User
    Join Date
    01-02-2024
    Location
    Sydney, Australia
    MS-Off Ver
    Microsoft 365 Apps for Enterprise (beta channel)
    Posts
    23

    Unhappy Get a list of worksheets that works in web and desktop without VBA

    I need to build a list of worksheet tabs in a workbook that keeps updated. I need it to work with the web, but the environment is locked down, so I can't use VBA.

    I use this list in the Dropdowns worksheet, cell C21, to filter the ones I want in E21, get some data in F21 and then fill in the !Data worksheet.

    On my desktop, I have used either of these Names formulas:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

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


    But on the web, I get "#NAME?" and no Name Manager or Defined Names option (which the Help says to use) in the Formulas tab.

    So, the solution to fix it from the MS KB doesn't work:
    Excel \ Formulas and functions \ Errors \ How to correct a #NAME? error


    Is there another option, or do I need to forget Excel and use something better?

    Regards,
    Mike
    Last edited by MikeInAu; 01-18-2024 at 05:52 PM.
    Regards,
    Mike

  2. #2
    Registered User
    Join Date
    01-02-2024
    Location
    Sydney, Australia
    MS-Off Ver
    Microsoft 365 Apps for Enterprise (beta channel)
    Posts
    23

    Re: Get a list of worksheets that works in web and desktop without VBA

    I think I've found a way around the problem using a Power Query that exposes the workbook metadata. Will do some more testing during the week unless anyone replies with a more elegant solution...


    Regards,
    Mike

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2411
    Posts
    26,673

    Re: Get a list of worksheets that works in web and desktop without VBA

    There is no way to get a list of worksheets (tabs) automatically without using some kind of macro. The web version of Excel does not support macros. Your formula uses GET.WORKBOOK. That is not a VBA macro, but it is an old Excel 4.0 macro, which also is not supported on the web version, and that is why you are getting a NAME error. Excel does not recognize the name GET.WORKBOOK.

    The web version has its own macro language Office Script, which can probably do this. I think it is available only on certain versions--when I bring up it up, it does not have the Automate tab on the Ribbon. I think you might need an enterprise license.

    The drawback of using Office Script for the web version is that your desktop version may not support it.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2411
    Posts
    26,673

    Re: Get a list of worksheets that works in web and desktop without VBA

    Quote Originally Posted by MikeInAu View Post
    Power Query that exposes the workbook metadata
    That sounds promising. I have not used PQ and am not familiar with its functionality available in the web version.

  5. #5
    Registered User
    Join Date
    01-02-2024
    Location
    Sydney, Australia
    MS-Off Ver
    Microsoft 365 Apps for Enterprise (beta channel)
    Posts
    23

    Re: Get a list of worksheets that works in web and desktop without VBA

    Quote Originally Posted by 6StringJazzer View Post
    That sounds promising. I have not used PQ and am not familiar with its functionality available in the web version.
    Hi Jeff,

    Aside from a warning on opening the file via the web that it might be unsafe, it seems to be working on both platforms. One odd thing - you have to disable OneDrive to set it up but must have OneDrive enabled for it to update.
    Annoying that Microsoft doesn't have a simple function to pull a list or array of sheet names that can then be filtered... I've seen so many questions and solutions that don't quite work in my searches.

    I'll try to post back with my solution once I've fully tested it.

    Mike

  6. #6
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,505

    Re: Get a list of worksheets that works in web and desktop without VBA

    In PQ it is just Get Data --> From file and then transform

    One click (select "Name" columns) and you are done

    PHP Code: 
    let
        Source 
    Excel.Workbook(File.Contents("C:\Users\xxx\Downloads\Book1.xlsm"), nulltrue),
        
    fltr_sheets Table.SelectRows(Sourceeach ([Kind] = "Sheet")),
        
    sheets_names Table.SelectColumns(fltr_sheets,{"Name"})
    in
        sheets_names 
    Last edited by JEC.; 01-06-2024 at 11:56 AM.

  7. #7
    Registered User
    Join Date
    01-02-2024
    Location
    Sydney, Australia
    MS-Off Ver
    Microsoft 365 Apps for Enterprise (beta channel)
    Posts
    23

    Re: Get a list of worksheets that works in web and desktop without VBA

    Quote Originally Posted by JEC. View Post
    In PQ it is just Get Data --> From file and then transform

    One click (select "Name" columns) and you are done
    JEC,

    Is there a way to make the PQ refer to the file when the file name changes?
    Also, to not refer to the local path so the file can be shared?

    Thanks,
    Mike

  8. #8
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,505

    Re: Get a list of worksheets that works in web and desktop without VBA

    The best way is to use Get Data --> From File --> From Sharepoint Folder (for this you need a specific office subscription) --> https://support.microsoft.com/en-us/...f-f2e1bfa0cb16
    This way, everyone with access to the folder can refresh the query. So, you are not bound to local paths.
    Furthermore, choosing the variable filename is possible while creating the query.

    If you don't have this "From Sharepoint Folder" option, you could go for Get Data From Web. Use the sharepoint URL.
    Not bound to a local path but not so easy to select the dynamic filename.

  9. #9
    Forum Expert
    Join Date
    10-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365 V2401 w/ Win10 Home 64 Bit
    Posts
    2,014

    Re: Get a list of worksheets that works in web and desktop without VBA

    Quote Originally Posted by MikeInAu View Post
    Annoying that Microsoft doesn't have a simple function to pull a list or array of sheet names that can then be filtered... I've seen so many questions and solutions that don't quite work in my searches.
    Mike
    Totally agree with that!!

  10. #10
    Forum Expert
    Join Date
    10-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365 V2401 w/ Win10 Home 64 Bit
    Posts
    2,014

    Re: Get a list of worksheets that works in web and desktop without VBA

    I did a test with Power Query and after creating a new sheet with the sheet names I saved the workbook and reloaded the query, then 3 new lines emerged.
    The red one isn't a sheet name, would it be a function?

    Excel 365 (Windows) 64 bit
    A
    1
    Name
    2
    Introduction
    3
    Value Drivers
    4
    Item (1)
    5
    Item (2)
    6
    Item (3)
    7
    Item (4)
    8
    Item (5)
    9
    Scorecard
    10
    pRankBy2
    11
    Dropdowns
    12
    !Data
    13
    Sample Qualitative Metrics
    14
    pRankBy2_1
    15
    _xlnm._FilterDatabase
    16
    DadosExternos_1
    17
    pRankBy21
    Sheet: pRankBy2
    Last edited by DJunqueira; 01-06-2024 at 02:32 PM.

  11. #11
    Forum Expert
    Join Date
    10-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365 V2401 w/ Win10 Home 64 Bit
    Posts
    2,014

    Re: Get a list of worksheets that works in web and desktop without VBA

    So I found that you need to filter first to load only sheet names.

    Attachment 854813

    By the way, the exact code that JEC pointed in message #6 (sorry for not noticing...)
    Last edited by DJunqueira; 01-06-2024 at 02:42 PM.

  12. #12
    Registered User
    Join Date
    01-02-2024
    Location
    Sydney, Australia
    MS-Off Ver
    Microsoft 365 Apps for Enterprise (beta channel)
    Posts
    23

    Re: Get a list of worksheets that works in web and desktop without VBA

    I still have a bit more testing to do, but it seems that JFC's idea might solve the problem.

    Hey JFC, how do I link to a list of the sheets?

  13. #13
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,505

    Re: Get a list of worksheets that works in web and desktop without VBA

    What are you trying to do with "linking" sheets. Are you trying to get data from these sheets? Can you give more info?

  14. #14
    Registered User
    Join Date
    01-02-2024
    Location
    Sydney, Australia
    MS-Off Ver
    Microsoft 365 Apps for Enterprise (beta channel)
    Posts
    23

    Re: Get a list of worksheets that works in web and desktop without VBA

    Quote Originally Posted by JEC. View Post
    What are you trying to do with "linking" sheets. Are you trying to get data from these sheets? Can you give more info?
    Does the attached help?

  15. #15
    Registered User
    Join Date
    01-02-2024
    Location
    Sydney, Australia
    MS-Off Ver
    Microsoft 365 Apps for Enterprise (beta channel)
    Posts
    23

    Re: Get a list of worksheets that works in web and desktop without VBA

    Quote Originally Posted by JEC. View Post
    What are you trying to do with "linking" sheets. Are you trying to get data from these sheets? Can you give more info?
    Still trying to work out the links, so they work ...

  16. #16
    Registered User
    Join Date
    01-02-2024
    Location
    Sydney, Australia
    MS-Off Ver
    Microsoft 365 Apps for Enterprise (beta channel)
    Posts
    23

    Re: Get a list of worksheets that works in web and desktop without VBA

    VCF v9 - Sharepoint or OneDrive

  17. #17
    Registered User
    Join Date
    01-02-2024
    Location
    Sydney, Australia
    MS-Off Ver
    Microsoft 365 Apps for Enterprise (beta channel)
    Posts
    23

    Re: Get a list of worksheets that works in web and desktop without VBA

    Quote Originally Posted by JEC. View Post
    The best way is to use Get Data --> From File --> From Sharepoint Folder
    Furthermore, choosing the variable filename is possible while creating the query.

    If you don't have this "From Sharepoint Folder" option, you could go for Get Data From Web. Use the sharepoint URL.
    Not bound to a local path but not so easy to select the dynamic filename.
    Hi JEC,

    I get it mostly working via OneDrive with this query:

    Please Login or Register  to view this content.
    But, it fails when the filename is changed.

    I do have a Sharepoint subscription... but not sure how to get the variable into the query:

    Please Login or Register  to view this content.
    The last query only shows the various files, rather than the sheets in my file.

  18. #18
    Forum Expert
    Join Date
    10-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365 V2401 w/ Win10 Home 64 Bit
    Posts
    2,014

    Re: Get a list of worksheets that works in web and desktop without VBA

    The best solution would be to import any file inside the folder and if they all follow the same structure use PQ to filter the data.

  19. #19
    Registered User
    Join Date
    01-02-2024
    Location
    Sydney, Australia
    MS-Off Ver
    Microsoft 365 Apps for Enterprise (beta channel)
    Posts
    23

    Re: Get a list of worksheets that works in web and desktop without VBA

    Quote Originally Posted by DJunqueira View Post
    The best solution would be to import any file inside the folder and if they all follow the same structure use PQ to filter the data.
    The issue is that it's a single workbook with multiple sheets.

  20. #20
    Forum Expert
    Join Date
    10-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365 V2401 w/ Win10 Home 64 Bit
    Posts
    2,014

    Re: Get a list of worksheets that works in web and desktop without VBA

    So you want to be able to insert a new name to the path to be loaded?

  21. #21
    Registered User
    Join Date
    01-02-2024
    Location
    Sydney, Australia
    MS-Off Ver
    Microsoft 365 Apps for Enterprise (beta channel)
    Posts
    23

    Re: Get a list of worksheets that works in web and desktop without VBA

    I want to be able to read all the sheets beginning with "Item..."

  22. #22
    Forum Expert
    Join Date
    10-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365 V2401 w/ Win10 Home 64 Bit
    Posts
    2,014

    Re: Get a list of worksheets that works in web and desktop without VBA

    For this you can go for the first "action" of PQ and filter, very simple.
    Could you prepare a good sample, so I can make a video for you?

  23. #23
    Registered User
    Join Date
    01-02-2024
    Location
    Sydney, Australia
    MS-Off Ver
    Microsoft 365 Apps for Enterprise (beta channel)
    Posts
    23

    Re: Get a list of worksheets that works in web and desktop without VBA

    Quote Originally Posted by DJunqueira View Post
    For this you can go for the first "action" of PQ and filter, very simple.
    Could you prepare a good sample, so I can make a video for you?
    Simply, I want it to get the list of sheets from the current workbook in a way that doesn't break if I save_as to a different path or filename.

    I can use OneDrive or Sharepoint, if that helps?

    Currently using the OD query:
    Please Login or Register  to view this content.
    JEC indicated that dynamic variables for the filename are possible (but easier with sharepoint), here:
    https://www.excelforum.com/excel-for...ml#post5907041

    Thanks,
    Mike

  24. #24
    Registered User
    Join Date
    01-02-2024
    Location
    Sydney, Australia
    MS-Off Ver
    Microsoft 365 Apps for Enterprise (beta channel)
    Posts
    23

    Smile Re: Get a list of worksheets that works in web and desktop without VBA

    Solved it!!!

    I created a hidden and named cell with this formula:
    = SUBSTITUTE(TEXTBEFORE(CELL("filename"),"]"),"[","")

    Then used this query:
    Please Login or Register  to view this content.
    Damn, Microsoft made this difficult! Considering they still have the Excel 4.0 macro - GET.WORKBOOK(1) - built-in, you'd think they could have made this a function so it could be used in templates that can be shared with others.
    Last edited by MikeInAu; 01-18-2024 at 01:56 PM.

  25. #25
    Registered User
    Join Date
    01-02-2024
    Location
    Sydney, Australia
    MS-Off Ver
    Microsoft 365 Apps for Enterprise (beta channel)
    Posts
    23

    Re: Get a list of worksheets that works in web and desktop without VBA

    Bugger!

    The CELL("filename") function doesn't work in web.

    And, even if I manually put in the field info, it can't refresh.

    Looks like it's not quite possible.

    Last edited by MikeInAu; 01-18-2024 at 05:24 PM.

  26. #26
    Forum Expert
    Join Date
    10-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365 V2401 w/ Win10 Home 64 Bit
    Posts
    2,014

    Re: Get a list of worksheets that works in web and desktop without VBA

    Are you aware that you have to follow an order of queries and functions inside of Power Query to all go as planned, aren't you?

  27. #27
    Registered User
    Join Date
    01-02-2024
    Location
    Sydney, Australia
    MS-Off Ver
    Microsoft 365 Apps for Enterprise (beta channel)
    Posts
    23

    Re: Get a list of worksheets that works in web and desktop without VBA

    Quote Originally Posted by DJunqueira View Post
    Are you aware that you have to follow an order of queries and functions inside of Power Query to all go as planned, aren't you?
    I wasn't... but, as I said, the issue (only with web) is before PQ is used. It's with the cell that gets the path, using the function =CELL("filename") -- This is fine on the desktop, but the "filename" part of the CELL() function doesn't work with Web.

  28. #28
    Forum Expert
    Join Date
    10-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365 V2401 w/ Win10 Home 64 Bit
    Posts
    2,014

    Re: Get a list of worksheets that works in web and desktop without VBA

    You can get images from internet with IMAGE() function, but can't get a file?
    Something wrong, stop insisting with CELL(), this is an old function.

  29. #29
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,505

    Re: Get a list of worksheets that works in web and desktop without VBA

    You can get the filename with Office scripts in Excel webversions but you have to run this script before running the Query. Not something that I would advice.
    Still I would retrieve your worbook with the "From Sharepoint Folder" connector. Give your file a flag which will allow you to select the most recent file in Power Query

  30. #30
    Registered User
    Join Date
    01-02-2024
    Location
    Sydney, Australia
    MS-Off Ver
    Microsoft 365 Apps for Enterprise (beta channel)
    Posts
    23

    Re: Get a list of worksheets that works in web and desktop without VBA

    Quote Originally Posted by DJunqueira View Post
    You can get images from internet with IMAGE() function, but can't get a file?
    Something wrong, stop insisting with CELL(), this is an old function.
    Can you recommend a better function?

    As a result, I need a list of the workbook tabs that I can filter and sort. It should automatically be updated and work from a desktop or the web. It can't use VBA or macros due to corporate lockdowns.

  31. #31
    Registered User
    Join Date
    01-02-2024
    Location
    Sydney, Australia
    MS-Off Ver
    Microsoft 365 Apps for Enterprise (beta channel)
    Posts
    23

    Re: Get a list of worksheets that works in web and desktop without VBA

    Quote Originally Posted by JEC. View Post
    You can get the filename with Office scripts in Excel webversions but you have to run this script before running the Query. Not something that I would advice.
    Still I would retrieve your worbook with the "From Sharepoint Folder" connector. Give your file a flag which will allow you to select the most recent file in Power Query
    Can the Sharepoint folder be a variable that works if the file is moved?

+ 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. [SOLVED] Excel app works on notebook, but not desktop
    By JeffLeites in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-12-2023, 11:47 PM
  2. Button that works in both Desktop and Web Excel
    By 6diegodiego9 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-03-2022, 02:46 AM
  3. [SOLVED] Macro works on desktop but not Network environment
    By PitchNinja in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-17-2021, 10:04 AM
  4. [SOLVED] Thisworkbook.path Works if on USB drive, but not if on Desktop
    By groundin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-23-2017, 08:22 AM
  5. Replies: 1
    Last Post: 01-09-2015, 10:43 PM
  6. Excel 2007 : Link worksheets from users desktop
    By Speich in forum Excel General
    Replies: 1
    Last Post: 06-10-2011, 12:52 PM
  7. Hyperlink Code only works when file saved on desktop
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-16-2005, 03:05 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