Help with Resizing?

ConnieEE

New Member
Joined
May 6, 2015
Messages
6
I'd like a worksheet to open with the window resized to display only the range A1:G16. The zoom needs to be 140%. Help with VBA please?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I'd like a worksheet to open with the window resized to display only the range A1:G16. The zoom needs to be 140%. Help with VBA please?
This is a start, but may need some tweaking to get what you want. Here I've assumed the sheet of interest is Sheet4 (code name of the sheet). The first event macro goes in Sheet4, the second goes in Thisworkbook.

Code:
Private Sub Worksheet_Activate()
Dim R As Range
Application.ScreenUpdating = False
Set R = Me.Range("A1:G16")
R.Select
With ActiveWindow
    .WindowState = xlNormal
    .Top = R.Top
    .Left = R.Left
    .Width = R.Width + 200  'Adjust the added value to suit
    .Height = R.Height + 160  'Adjust the added value to suit
    .Zoom = 140
End With
Application.ScreenUpdating = True
End Sub
Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Application.ScreenUpdating = False
If Sh.CodeName <> "Sheet4" Then
    ActiveWindow.WindowState = xlMaximized
End If
Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0
Another option

Sub hide()


Range("H:XFD").EntireColumn.Hidden = True
Range("G17:G1048576").EntireRow.Hidden = True


ActiveWindow.Zoom = 140


End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,071
Latest member
cdnMech

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