VBA Zoom to Selection

rickwithers

New Member
Joined
Sep 13, 2013
Messages
12
I have the following code to try to zoom to a selection dependent on the worksheet being opened:

zArea = "A1:" & Range("BA6").value (Sets String zArea to A1: and the last cell in range as given in cell BA6 on each worksheet)

Range(zArea).Select

ActiveWindow.Zoom = True

The problem I have is the correct sheet opens, but the zoom level defaults to 400% at cell A1. For one particular worksheet, cell BA6 = AH61, therefore zArea = A1:AH61. Using MsgBox confirmed the value, however, the Zoom property doesn't accept it. Any suggestions?
 
Sorry, now I got you. No it is not selected.

UPDATE: Yes it is selected, once I commented out the ActiveSheet.Protect
 
Last edited:
Upvote 0
MrExcel MVP

Thanks for nudging me in the right direction. After commenting out the ActiveSheet.Protect line in the Open_Ref module, it appears to work. I'm not sure why the protection was added except to prevent manipulation of any formulae in the wprksheets. I guess I'll just have to trust users not to mess it up.

Again, thanks for the guidance; it helped start me thinking and along with the help of everyone replying to this post, get the problem solved.
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top