Can't see named range for table when worksheet is hidden












1















I'm trying to access a named range via VBA:



Set rng = selectionSht.Parent.Names(rangeName).RefersToRange


However, this particular named range is mapped to a table on a hidden worksheet. When the worksheet is hidden, the named range disappears from the list of named ranges shown when I go to Formulas->Name Manager, but it reappears in the list when I unhide the sheet. This does not happen to other named ranges that refer to static ranges--it seems to only be an issue for named ranges that correspond to tables.



When the sheet is hidden, the above line of VBA code returns:



Run-time error '1004':
Application-defined or object-defined error


How can I make this named range readable when the sheet is hidden?










share|improve this question


















  • 2





    As far as I know, I don't think you can. Some VBA functions only work on what is visible. I.E. if you had a cell with width set to 0, it treats it as hidden and as something you can't access. What you may want to do is to put screen updating = false, show the hidden worksheet, do what you need to with the named range, make the worksheet hidden again, and then turn on screen updating = true. From the perspective of the user, they still never see the hidden worksheet

    – Eric F
    Jan 29 at 20:32






  • 1





    @EricF, that sounds like an answer.

    – fixer1234
    Jan 29 at 22:26
















1















I'm trying to access a named range via VBA:



Set rng = selectionSht.Parent.Names(rangeName).RefersToRange


However, this particular named range is mapped to a table on a hidden worksheet. When the worksheet is hidden, the named range disappears from the list of named ranges shown when I go to Formulas->Name Manager, but it reappears in the list when I unhide the sheet. This does not happen to other named ranges that refer to static ranges--it seems to only be an issue for named ranges that correspond to tables.



When the sheet is hidden, the above line of VBA code returns:



Run-time error '1004':
Application-defined or object-defined error


How can I make this named range readable when the sheet is hidden?










share|improve this question


















  • 2





    As far as I know, I don't think you can. Some VBA functions only work on what is visible. I.E. if you had a cell with width set to 0, it treats it as hidden and as something you can't access. What you may want to do is to put screen updating = false, show the hidden worksheet, do what you need to with the named range, make the worksheet hidden again, and then turn on screen updating = true. From the perspective of the user, they still never see the hidden worksheet

    – Eric F
    Jan 29 at 20:32






  • 1





    @EricF, that sounds like an answer.

    – fixer1234
    Jan 29 at 22:26














1












1








1








I'm trying to access a named range via VBA:



Set rng = selectionSht.Parent.Names(rangeName).RefersToRange


However, this particular named range is mapped to a table on a hidden worksheet. When the worksheet is hidden, the named range disappears from the list of named ranges shown when I go to Formulas->Name Manager, but it reappears in the list when I unhide the sheet. This does not happen to other named ranges that refer to static ranges--it seems to only be an issue for named ranges that correspond to tables.



When the sheet is hidden, the above line of VBA code returns:



Run-time error '1004':
Application-defined or object-defined error


How can I make this named range readable when the sheet is hidden?










share|improve this question














I'm trying to access a named range via VBA:



Set rng = selectionSht.Parent.Names(rangeName).RefersToRange


However, this particular named range is mapped to a table on a hidden worksheet. When the worksheet is hidden, the named range disappears from the list of named ranges shown when I go to Formulas->Name Manager, but it reappears in the list when I unhide the sheet. This does not happen to other named ranges that refer to static ranges--it seems to only be an issue for named ranges that correspond to tables.



When the sheet is hidden, the above line of VBA code returns:



Run-time error '1004':
Application-defined or object-defined error


How can I make this named range readable when the sheet is hidden?







microsoft-excel microsoft-excel-2010 vba






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 29 at 20:23









sigilsigil

2953822




2953822








  • 2





    As far as I know, I don't think you can. Some VBA functions only work on what is visible. I.E. if you had a cell with width set to 0, it treats it as hidden and as something you can't access. What you may want to do is to put screen updating = false, show the hidden worksheet, do what you need to with the named range, make the worksheet hidden again, and then turn on screen updating = true. From the perspective of the user, they still never see the hidden worksheet

    – Eric F
    Jan 29 at 20:32






  • 1





    @EricF, that sounds like an answer.

    – fixer1234
    Jan 29 at 22:26














  • 2





    As far as I know, I don't think you can. Some VBA functions only work on what is visible. I.E. if you had a cell with width set to 0, it treats it as hidden and as something you can't access. What you may want to do is to put screen updating = false, show the hidden worksheet, do what you need to with the named range, make the worksheet hidden again, and then turn on screen updating = true. From the perspective of the user, they still never see the hidden worksheet

    – Eric F
    Jan 29 at 20:32






  • 1





    @EricF, that sounds like an answer.

    – fixer1234
    Jan 29 at 22:26








2




2





As far as I know, I don't think you can. Some VBA functions only work on what is visible. I.E. if you had a cell with width set to 0, it treats it as hidden and as something you can't access. What you may want to do is to put screen updating = false, show the hidden worksheet, do what you need to with the named range, make the worksheet hidden again, and then turn on screen updating = true. From the perspective of the user, they still never see the hidden worksheet

– Eric F
Jan 29 at 20:32





As far as I know, I don't think you can. Some VBA functions only work on what is visible. I.E. if you had a cell with width set to 0, it treats it as hidden and as something you can't access. What you may want to do is to put screen updating = false, show the hidden worksheet, do what you need to with the named range, make the worksheet hidden again, and then turn on screen updating = true. From the perspective of the user, they still never see the hidden worksheet

– Eric F
Jan 29 at 20:32




1




1





@EricF, that sounds like an answer.

– fixer1234
Jan 29 at 22:26





@EricF, that sounds like an answer.

– fixer1234
Jan 29 at 22:26










1 Answer
1






active

oldest

votes


















3














You can't directly do what you want. In VBA, if a cell is not visible to the user, then VBA also can't see it. For example if you set a cell's width to 0, VBA treats that as not visible and therefore you can't access it, similar to what you have above.



The way you can achieve a task while keeping a cell / row / column hidden is to do the following:




  1. Turn Application.ScreenUpdating = False


  2. .Show the hidden area that you are referrencing

  3. Perform whatever operation you need to do to the given cells


  4. .Hide the area that you worked on

  5. Turn Application.ScreenUpdating = True back on.


From the user's standpoint since screenupdating was off, the cell / row / column never was shown but you can still achieve your task.






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1399798%2fcant-see-named-range-for-table-when-worksheet-is-hidden%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    You can't directly do what you want. In VBA, if a cell is not visible to the user, then VBA also can't see it. For example if you set a cell's width to 0, VBA treats that as not visible and therefore you can't access it, similar to what you have above.



    The way you can achieve a task while keeping a cell / row / column hidden is to do the following:




    1. Turn Application.ScreenUpdating = False


    2. .Show the hidden area that you are referrencing

    3. Perform whatever operation you need to do to the given cells


    4. .Hide the area that you worked on

    5. Turn Application.ScreenUpdating = True back on.


    From the user's standpoint since screenupdating was off, the cell / row / column never was shown but you can still achieve your task.






    share|improve this answer




























      3














      You can't directly do what you want. In VBA, if a cell is not visible to the user, then VBA also can't see it. For example if you set a cell's width to 0, VBA treats that as not visible and therefore you can't access it, similar to what you have above.



      The way you can achieve a task while keeping a cell / row / column hidden is to do the following:




      1. Turn Application.ScreenUpdating = False


      2. .Show the hidden area that you are referrencing

      3. Perform whatever operation you need to do to the given cells


      4. .Hide the area that you worked on

      5. Turn Application.ScreenUpdating = True back on.


      From the user's standpoint since screenupdating was off, the cell / row / column never was shown but you can still achieve your task.






      share|improve this answer


























        3












        3








        3







        You can't directly do what you want. In VBA, if a cell is not visible to the user, then VBA also can't see it. For example if you set a cell's width to 0, VBA treats that as not visible and therefore you can't access it, similar to what you have above.



        The way you can achieve a task while keeping a cell / row / column hidden is to do the following:




        1. Turn Application.ScreenUpdating = False


        2. .Show the hidden area that you are referrencing

        3. Perform whatever operation you need to do to the given cells


        4. .Hide the area that you worked on

        5. Turn Application.ScreenUpdating = True back on.


        From the user's standpoint since screenupdating was off, the cell / row / column never was shown but you can still achieve your task.






        share|improve this answer













        You can't directly do what you want. In VBA, if a cell is not visible to the user, then VBA also can't see it. For example if you set a cell's width to 0, VBA treats that as not visible and therefore you can't access it, similar to what you have above.



        The way you can achieve a task while keeping a cell / row / column hidden is to do the following:




        1. Turn Application.ScreenUpdating = False


        2. .Show the hidden area that you are referrencing

        3. Perform whatever operation you need to do to the given cells


        4. .Hide the area that you worked on

        5. Turn Application.ScreenUpdating = True back on.


        From the user's standpoint since screenupdating was off, the cell / row / column never was shown but you can still achieve your task.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 30 at 13:54









        Eric FEric F

        2,80031331




        2,80031331






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1399798%2fcant-see-named-range-for-table-when-worksheet-is-hidden%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

            is 'sed' thread safe

            How to make a Squid Proxy server?