Automatically Zoom Upon Opening

R

RickGreg

Some time ago, the great folks here helped me with some code to
automatically resize worksheets to fit the screen. I retained the code that
re-sizes sheets when the user moves from one sheet to another, but I can't
find the code that will automatically re-size the first sheet upon opening
the workbook file.

For example, if sheet1 is "Intro", I would like to fit cells A1:H21 to fill
the window when the file is first opened.

Can someone help with this (again)?! Thank you!

FWIW, here's the code I'm using on other pages:

Private Sub Worksheet_Activate()
Me.Range("A1:k27").Select
Application.ActiveWindow.Zoom = True
Me.Range("i9").Select
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

End Sub
 
J

JE McGimpsey

RickGreg said:
Some time ago, the great folks here helped me with some code to
automatically resize worksheets to fit the screen. I retained the code that
re-sizes sheets when the user moves from one sheet to another, but I can't
find the code that will automatically re-size the first sheet upon opening
the workbook file.

For example, if sheet1 is "Intro", I would like to fit cells A1:H21 to fill
the window when the file is first opened.

Can someone help with this (again)?! Thank you!

Put this in the ThisWorkbook code module:


Private Sub Workbook_Open()
With Sheet1
.Activate
.Range("A1:H21").Select
End With
ActiveWindow.Zoom = True
End Sub



(see

http://www.mcgimpsey.com/excel/modules.html

if you're not sure where that is)
 
R

RickGreg

Put this in the ThisWorkbook code module:


Private Sub Workbook_Open()
With Sheet1
.Activate
.Range("A1:H21").Select
End With
ActiveWindow.Zoom = True
End Sub



(see

http://www.mcgimpsey.com/excel/modules.html

if you're not sure where that is)

Works great. One more question. After the zoom to a1:h21 is accomplished,
is there a way to leave only cell d8 selected? Thanks for the help!
 
J

JE McGimpsey

RickGreg said:
Works great. One more question. After the zoom to a1:h21 is accomplished,
is there a way to leave only cell d8 selected? Thanks for the help!

One way:

Private Sub Workbook_Open()
With Sheet1
.Activate
.Range("A1:H21").Select
ActiveWindow.Zoom = True
.Range("D8").Select
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top