The_Steward
Board Regular
- Joined
- Nov 26, 2020
- Messages
- 63
- Office Version
- 365
- Platform
- Windows
Hello,
I am currently using below code to try automatically display same screen for different screen sizes on multiple worksheets. Cell range adjusted depending on Cell range width.
However, I found that while this would work for some sheets it wouldn't work for others. Everything would line up perfectly on 13 inch screen but not 24inch and vice versa. I tried measuring and re-adjusting cells width to exactly same size within selected area but this has not worked yet either. What am I doing wrong? Any help would be greatly appreciated.
Code for measuring selected area width
I am currently using below code to try automatically display same screen for different screen sizes on multiple worksheets. Cell range adjusted depending on Cell range width.
VBA Code:
Private Sub Worksheet_Activate()
Sheet1.Range("B1:O30").Select
ActiveWindow.Zoom = True
Range("A1").Select
End Sub
However, I found that while this would work for some sheets it wouldn't work for others. Everything would line up perfectly on 13 inch screen but not 24inch and vice versa. I tried measuring and re-adjusting cells width to exactly same size within selected area but this has not worked yet either. What am I doing wrong? Any help would be greatly appreciated.
Code for measuring selected area width
VBA Code:
Sub MeasureSelection_Points()
Dim cell As Range
Dim Width As Double
Dim Height As Double
'Measure Selection Height
For Each cell In Selection.Cells.Columns(1)
Height = Height + cell.Height
Next cell
'Measure Selection Width
For Each cell In Selection.Cells.Rows(1)
Width = Width + cell.Width
Next cell
'Report Results
MsgBox "Height: " & Round(Height / 72, 2) & "pts" & vbCr & "Width: " _
& Round(Width / 72, 2) & "pts", , "Dimensions"
End Sub