I have a Validated Dropdown list in Excel that is unreadable if zoom is less than 100. I checked on the internet and fvound that I can not alter the size of the Validated list text size so I want to enforce a set zoom of 100.
I have the code to do this as follows
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveWindow.Zoom = 100
End Sub
This works and is fine for people who use zoom less than 100, but if people use a greater than 100 zoom it restricts the zoom to 100. Is there a way to overcome this, something along the lines of an If-Else statement.
If zoom less than 100 then zoom = 100 else if zoom greater than 100 do nothing
Thanks.
Change the zoom functions of the mouse scroll wheel By default the wheel will scroll up and down the page, but with Ctrl + mouse scroll will zoom into an Excel worksheet. With VBA it is possible to reverse these settings when used within Excel.
You can do this by right-clicking on an empty space of the status bar, which displays a Context menu. At the bottom of the Context menu, click on the Zoom Slider option. This should remove the check mark from that option and, in the process, remove the Zoom slider from the status bar.
In VBA, you can use one IF statement inside another IF statement to create nested IFs. In simple words, you can execute one test statement using IF based on the result of another IF statement. In this kind of conditional statement, you need to test complex conditions.
To begin single stepping while a macro is running, press CTRL+BREAK. To begin single stepping at a specific point in your macro, you can add the SingleStep macro action to your macro at the point where you want single stepping to begin.
If (ActiveWindow.Zoom < 100) Then
ActiveWindow.Zoom = 100
End If
Here's a one-liner that will do the same thing:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveWindow.Zoom = Application.Max(ActiveWindow.Zoom, 100)
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With