Page sizing in a Macro

Dan Wilson

Well-known Member
Joined
Feb 5, 2006
Messages
536
Office Version
  1. 365
Platform
  1. Windows
Good day. I am using Excel 2013 on Windows 10 Pro. I have a workbook that contains 5 worksheets. Each worksheet allows the user to enter data into rows that reach out to Column EA. Column A contains data that is necessary to be visible while entering data out in the far end of the worksheet (for example - name). To make this happen I use the Control Key in conjunction with the mouse to reduce the viewable size of the page. Sometimes I forget to return the size to normal.
In addition to this, there are Macros that allow each of the various worksheets to be sorted in as many as 5 different ways.
As the entire workbook opens up for the first time, there is a Macro that runs to reset each worksheet to its nominal sort condition.
Is there a statement that I can add to the Reset Macro to make each worksheet display with a preset Row Height and Cell Width?
Thank you for any help with this.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
To reset the size to normal you can use the following code. It's based on view percentage, not preset row height though. Put this code in the ThisWorkbook code section, and it will run every time the workbook is open.

Code:
Private Sub Workbook_Open()
    Dim ws As Worksheet, wOpen as Worksheet
    Set wOpen = ActiveSheet
    For Each ws In ActiveWorkbook.Worksheets
        ws.Activate
        ActiveWindow.Zoom = 100
    Next ws
    wOpen.Activate
End Sub

To reset the sorting, it's too hard to provide an answer without knowing more data about the sort range. However, you can probably get most of the answer yourself by recording a macro while setting the sorting how you want it. Then, you can use that code after the ActiveWindow.Zoom statement above (before the Next ws). If the recorded code is generic (e.g., no code identifying the specific worksheet, etc.), it should work on all pages without further modification. If not, you might have to change the specific code to generic code first.
 
Upvote 0
Good day shknbk2. Your fix is exactly what I wanted. It works perfectly. Thank you!
Dan Wilson...
 
Upvote 0

Forum statistics

Threads
1,223,755
Messages
6,174,318
Members
452,555
Latest member
colc007

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