Set Visible Range

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I can detect the visible range in the active worksheet with:

Sub Macro1()
Dim r As Range
Dim s As String
Set r = ActiveWindow.VisibleRange
s = r.Address
MsgBox (s)
End Sub

When, however, I try to setup the visible range with:

Sub Macro2()
Dim s As String
s = "$A$1:Z$100"
ActiveWindow.VisibleRange = Range(s)
End Sub

Nothing happens.

How can I adjust the scrollbars and zoom so that the upper left-hand cell is
A1 and the lower right-hand cell is Z100 using VBA?

Thanks in Advance
 
Range("A1:Z100").Select
ActiveWindow.Zoom = True

Excel will do the best it can to meet that - as a minimum, the range will be
visible and at least one constraint will be bounding - but that rectangle
may not meet the dimensions of your computers resolution or the Excel Window
size if your a windowed.
 
VisibleRange is a read-only property.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 

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

Back
Top