+ Reply to Thread
Results 1 to 4 of 4

Thread: Set Visible Range

  1. #1
    Gary''s Student
    Guest

    Set Visible Range

    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
    --
    Gary's Student

  2. #2
    Tom Ogilvy
    Guest

    Re: Set Visible Range

    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.

    --
    Regards,
    Tom Ogilvy



    "Gary''s Student" <GarysStudent@discussions.microsoft.com> wrote in message
    news:FC46D85F-A039-4DA8-9911-218F6C0ED54D@microsoft.com...
    > 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
    > --
    > Gary's Student




  3. #3
    Bob Phillips
    Guest

    Re: Set Visible Range

    VisibleRange is a read-only property.

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "Gary''s Student" <GarysStudent@discussions.microsoft.com> wrote in message
    news:FC46D85F-A039-4DA8-9911-218F6C0ED54D@microsoft.com...
    > 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
    > --
    > Gary's Student




  4. #4
    Gary''s Student
    Guest

    Re: Set Visible Range

    Thank you Tom
    Worked like a charm
    --
    Gary's Student


    "Tom Ogilvy" wrote:

    > 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.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    >
    > "Gary''s Student" <GarysStudent@discussions.microsoft.com> wrote in message
    > news:FC46D85F-A039-4DA8-9911-218F6C0ED54D@microsoft.com...
    > > 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
    > > --
    > > Gary's Student

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0