Zoom Fit to Selection automatically





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















hello to the community & Happy New Year 2019 :)



I recently changed my computer and at my surprise, I never considered that a different screen resolution could change my excel dashboard to not fit anymore into one window.
I had a look into few VBA suggestions, but I cannot really find a solution that could apply for a multiple worksheets, with each having a specific cells range to fit it back into one window automatically, and only running once, not continuously.



I have already a coding into my main workbook as the following, so I'm struggling to understand if it has to fit through the workbook or as a new module.



Private Sub Workbook_Open()
Worksheets("Dashboard").Activate
LoginFlag = False
Login.Show
End Sub


Question : How could I insert a VBA that would auto-size a range selection for specific worksheets that would look as the below?



Dashboard.Range("A1:AD36").Select 
ActiveWindow.Zoom = True


Thanks as always for the reading and taking the time on this problem.










share|improve this question





























    0















    hello to the community & Happy New Year 2019 :)



    I recently changed my computer and at my surprise, I never considered that a different screen resolution could change my excel dashboard to not fit anymore into one window.
    I had a look into few VBA suggestions, but I cannot really find a solution that could apply for a multiple worksheets, with each having a specific cells range to fit it back into one window automatically, and only running once, not continuously.



    I have already a coding into my main workbook as the following, so I'm struggling to understand if it has to fit through the workbook or as a new module.



    Private Sub Workbook_Open()
    Worksheets("Dashboard").Activate
    LoginFlag = False
    Login.Show
    End Sub


    Question : How could I insert a VBA that would auto-size a range selection for specific worksheets that would look as the below?



    Dashboard.Range("A1:AD36").Select 
    ActiveWindow.Zoom = True


    Thanks as always for the reading and taking the time on this problem.










    share|improve this question

























      0












      0








      0








      hello to the community & Happy New Year 2019 :)



      I recently changed my computer and at my surprise, I never considered that a different screen resolution could change my excel dashboard to not fit anymore into one window.
      I had a look into few VBA suggestions, but I cannot really find a solution that could apply for a multiple worksheets, with each having a specific cells range to fit it back into one window automatically, and only running once, not continuously.



      I have already a coding into my main workbook as the following, so I'm struggling to understand if it has to fit through the workbook or as a new module.



      Private Sub Workbook_Open()
      Worksheets("Dashboard").Activate
      LoginFlag = False
      Login.Show
      End Sub


      Question : How could I insert a VBA that would auto-size a range selection for specific worksheets that would look as the below?



      Dashboard.Range("A1:AD36").Select 
      ActiveWindow.Zoom = True


      Thanks as always for the reading and taking the time on this problem.










      share|improve this question














      hello to the community & Happy New Year 2019 :)



      I recently changed my computer and at my surprise, I never considered that a different screen resolution could change my excel dashboard to not fit anymore into one window.
      I had a look into few VBA suggestions, but I cannot really find a solution that could apply for a multiple worksheets, with each having a specific cells range to fit it back into one window automatically, and only running once, not continuously.



      I have already a coding into my main workbook as the following, so I'm struggling to understand if it has to fit through the workbook or as a new module.



      Private Sub Workbook_Open()
      Worksheets("Dashboard").Activate
      LoginFlag = False
      Login.Show
      End Sub


      Question : How could I insert a VBA that would auto-size a range selection for specific worksheets that would look as the below?



      Dashboard.Range("A1:AD36").Select 
      ActiveWindow.Zoom = True


      Thanks as always for the reading and taking the time on this problem.







      vba zoom






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 3 at 22:08









      GuillaumeGuillaume

      115




      115
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Hopefully I understood your question. I think the code below should help you.



          Private Sub Workbook_Open()
          Dim s1 As Worksheet
          Set s1 = Worksheets("Dashboard")
          Dim s2 As Sheet2
          Set s2 = Sheet2
          s1.Activate
          s1.Range("C1:D8").Select
          ActiveWindow.Zoom = True
          s2.Activate
          s2.Range("A1:B10").Select
          ActiveWindow.Zoom = True

          End Sub





          share|improve this answer


























          • Thank you very much RCL, would you know how to fit your coding proposal into the existing workbook VBA I have?

            – Guillaume
            Jan 3 at 22:33











          • Hi I have updated the answer. Is that what you mean?

            – RCL
            Jan 3 at 22:38











          • Hi, it is more how would you fit the coding with Worksheets("Dashboard").Activate LoginFlag = False Login.Show into the VBA code you are proposing, should this occurs after the login, or before the login, would the user as well see the update of the worksheets size, or is it into the background?

            – Guillaume
            Jan 3 at 22:53













          • That would be up to you. You can do it before or after the login form appears. If you don't want to the user to see the changes in the background I suggest you use Application.screenupdating = false. I suggest you test it and see what you prefer but what you prefer might be different to what the user prefer. Also don't forget to set the Application.screenupdating back to true once the background work is done.

            – RCL
            Jan 3 at 23:09













          • it worked perfectly, thanks a lot for your prompt help RCL.

            – Guillaume
            Jan 3 at 23:16












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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%2fstackoverflow.com%2fquestions%2f54030461%2fzoom-fit-to-selection-automatically%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









          0














          Hopefully I understood your question. I think the code below should help you.



          Private Sub Workbook_Open()
          Dim s1 As Worksheet
          Set s1 = Worksheets("Dashboard")
          Dim s2 As Sheet2
          Set s2 = Sheet2
          s1.Activate
          s1.Range("C1:D8").Select
          ActiveWindow.Zoom = True
          s2.Activate
          s2.Range("A1:B10").Select
          ActiveWindow.Zoom = True

          End Sub





          share|improve this answer


























          • Thank you very much RCL, would you know how to fit your coding proposal into the existing workbook VBA I have?

            – Guillaume
            Jan 3 at 22:33











          • Hi I have updated the answer. Is that what you mean?

            – RCL
            Jan 3 at 22:38











          • Hi, it is more how would you fit the coding with Worksheets("Dashboard").Activate LoginFlag = False Login.Show into the VBA code you are proposing, should this occurs after the login, or before the login, would the user as well see the update of the worksheets size, or is it into the background?

            – Guillaume
            Jan 3 at 22:53













          • That would be up to you. You can do it before or after the login form appears. If you don't want to the user to see the changes in the background I suggest you use Application.screenupdating = false. I suggest you test it and see what you prefer but what you prefer might be different to what the user prefer. Also don't forget to set the Application.screenupdating back to true once the background work is done.

            – RCL
            Jan 3 at 23:09













          • it worked perfectly, thanks a lot for your prompt help RCL.

            – Guillaume
            Jan 3 at 23:16
















          0














          Hopefully I understood your question. I think the code below should help you.



          Private Sub Workbook_Open()
          Dim s1 As Worksheet
          Set s1 = Worksheets("Dashboard")
          Dim s2 As Sheet2
          Set s2 = Sheet2
          s1.Activate
          s1.Range("C1:D8").Select
          ActiveWindow.Zoom = True
          s2.Activate
          s2.Range("A1:B10").Select
          ActiveWindow.Zoom = True

          End Sub





          share|improve this answer


























          • Thank you very much RCL, would you know how to fit your coding proposal into the existing workbook VBA I have?

            – Guillaume
            Jan 3 at 22:33











          • Hi I have updated the answer. Is that what you mean?

            – RCL
            Jan 3 at 22:38











          • Hi, it is more how would you fit the coding with Worksheets("Dashboard").Activate LoginFlag = False Login.Show into the VBA code you are proposing, should this occurs after the login, or before the login, would the user as well see the update of the worksheets size, or is it into the background?

            – Guillaume
            Jan 3 at 22:53













          • That would be up to you. You can do it before or after the login form appears. If you don't want to the user to see the changes in the background I suggest you use Application.screenupdating = false. I suggest you test it and see what you prefer but what you prefer might be different to what the user prefer. Also don't forget to set the Application.screenupdating back to true once the background work is done.

            – RCL
            Jan 3 at 23:09













          • it worked perfectly, thanks a lot for your prompt help RCL.

            – Guillaume
            Jan 3 at 23:16














          0












          0








          0







          Hopefully I understood your question. I think the code below should help you.



          Private Sub Workbook_Open()
          Dim s1 As Worksheet
          Set s1 = Worksheets("Dashboard")
          Dim s2 As Sheet2
          Set s2 = Sheet2
          s1.Activate
          s1.Range("C1:D8").Select
          ActiveWindow.Zoom = True
          s2.Activate
          s2.Range("A1:B10").Select
          ActiveWindow.Zoom = True

          End Sub





          share|improve this answer















          Hopefully I understood your question. I think the code below should help you.



          Private Sub Workbook_Open()
          Dim s1 As Worksheet
          Set s1 = Worksheets("Dashboard")
          Dim s2 As Sheet2
          Set s2 = Sheet2
          s1.Activate
          s1.Range("C1:D8").Select
          ActiveWindow.Zoom = True
          s2.Activate
          s2.Range("A1:B10").Select
          ActiveWindow.Zoom = True

          End Sub






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 3 at 22:37

























          answered Jan 3 at 22:25









          RCLRCL

          26028




          26028













          • Thank you very much RCL, would you know how to fit your coding proposal into the existing workbook VBA I have?

            – Guillaume
            Jan 3 at 22:33











          • Hi I have updated the answer. Is that what you mean?

            – RCL
            Jan 3 at 22:38











          • Hi, it is more how would you fit the coding with Worksheets("Dashboard").Activate LoginFlag = False Login.Show into the VBA code you are proposing, should this occurs after the login, or before the login, would the user as well see the update of the worksheets size, or is it into the background?

            – Guillaume
            Jan 3 at 22:53













          • That would be up to you. You can do it before or after the login form appears. If you don't want to the user to see the changes in the background I suggest you use Application.screenupdating = false. I suggest you test it and see what you prefer but what you prefer might be different to what the user prefer. Also don't forget to set the Application.screenupdating back to true once the background work is done.

            – RCL
            Jan 3 at 23:09













          • it worked perfectly, thanks a lot for your prompt help RCL.

            – Guillaume
            Jan 3 at 23:16



















          • Thank you very much RCL, would you know how to fit your coding proposal into the existing workbook VBA I have?

            – Guillaume
            Jan 3 at 22:33











          • Hi I have updated the answer. Is that what you mean?

            – RCL
            Jan 3 at 22:38











          • Hi, it is more how would you fit the coding with Worksheets("Dashboard").Activate LoginFlag = False Login.Show into the VBA code you are proposing, should this occurs after the login, or before the login, would the user as well see the update of the worksheets size, or is it into the background?

            – Guillaume
            Jan 3 at 22:53













          • That would be up to you. You can do it before or after the login form appears. If you don't want to the user to see the changes in the background I suggest you use Application.screenupdating = false. I suggest you test it and see what you prefer but what you prefer might be different to what the user prefer. Also don't forget to set the Application.screenupdating back to true once the background work is done.

            – RCL
            Jan 3 at 23:09













          • it worked perfectly, thanks a lot for your prompt help RCL.

            – Guillaume
            Jan 3 at 23:16

















          Thank you very much RCL, would you know how to fit your coding proposal into the existing workbook VBA I have?

          – Guillaume
          Jan 3 at 22:33





          Thank you very much RCL, would you know how to fit your coding proposal into the existing workbook VBA I have?

          – Guillaume
          Jan 3 at 22:33













          Hi I have updated the answer. Is that what you mean?

          – RCL
          Jan 3 at 22:38





          Hi I have updated the answer. Is that what you mean?

          – RCL
          Jan 3 at 22:38













          Hi, it is more how would you fit the coding with Worksheets("Dashboard").Activate LoginFlag = False Login.Show into the VBA code you are proposing, should this occurs after the login, or before the login, would the user as well see the update of the worksheets size, or is it into the background?

          – Guillaume
          Jan 3 at 22:53







          Hi, it is more how would you fit the coding with Worksheets("Dashboard").Activate LoginFlag = False Login.Show into the VBA code you are proposing, should this occurs after the login, or before the login, would the user as well see the update of the worksheets size, or is it into the background?

          – Guillaume
          Jan 3 at 22:53















          That would be up to you. You can do it before or after the login form appears. If you don't want to the user to see the changes in the background I suggest you use Application.screenupdating = false. I suggest you test it and see what you prefer but what you prefer might be different to what the user prefer. Also don't forget to set the Application.screenupdating back to true once the background work is done.

          – RCL
          Jan 3 at 23:09







          That would be up to you. You can do it before or after the login form appears. If you don't want to the user to see the changes in the background I suggest you use Application.screenupdating = false. I suggest you test it and see what you prefer but what you prefer might be different to what the user prefer. Also don't forget to set the Application.screenupdating back to true once the background work is done.

          – RCL
          Jan 3 at 23:09















          it worked perfectly, thanks a lot for your prompt help RCL.

          – Guillaume
          Jan 3 at 23:16





          it worked perfectly, thanks a lot for your prompt help RCL.

          – Guillaume
          Jan 3 at 23:16




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • 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%2fstackoverflow.com%2fquestions%2f54030461%2fzoom-fit-to-selection-automatically%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

          Angular Downloading a file using contenturl with Basic Authentication

          Monofisismo

          Olmecas