Zoom Fit to Selection automatically

Multi tool use
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
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
add a comment |
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
add a comment |
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
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
vba zoom
asked Jan 3 at 22:08


GuillaumeGuillaume
115
115
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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
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 useApplication.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 theApplication.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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
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 useApplication.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 theApplication.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
add a comment |
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
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 useApplication.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 theApplication.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
add a comment |
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
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
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 useApplication.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 theApplication.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
add a comment |
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 useApplication.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 theApplication.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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
yiWaIfkYUxyPgUDhRse