Use VBA to resize the window

NickDC1964

New Member
Joined
Mar 23, 2018
Messages
3
I'm trying to create a spreadsheet for a client that will automatically size itself to a specific size when it is opened. I've googled a dozen things, none of which seem to work. The most common seems to be this code:

Sub SetWindowSize1()
Application.WindowState = xlNormal
Application.Top = 25
Application.Left = 25
Application.Width = 300
Application.Height = 200
End Sub

But Excel hangs up every time. All I need is for the spreadsheet to resize its own window to a set size that I pick when it opens. Any suggestions?
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
When I put the code in the Workbook Open Event, it seems to work ok for me.

Code:
Private Sub Workbook_Open()
Application.WindowState = xlNormal
Application.Top = 25
Application.Left = 25
Application.Width = 300
Application.Height = 200
End Sub

I'm using Win 10 and Office 2016
 
Last edited:
Upvote 0
Thanks, I figured out the problem - the code doesn’t work on Excel for Mac, but works fine on Windows. I’d been doing the design work on my Mac.
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,496
Members
449,089
Latest member
Raviguru

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