Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Dallas, Texas, USA
    Posts
    1,680
    Thanks
    0
    Thanked 1 Time in 1 Post

    Compile error: (XL2000 SR-1)

    In the (Sheet1) object I have inserted the following code in an attempt to set the view on the end-users screen to a selected area. I would want to use a similar device for each of the screens (sheets) twhere the user has access. But I can't get past this first one, it creates an error when I run it. Compile error: Variable not defined.

    <font color=blue>Option Explicit

    Private Sub Worksheet_Activate()
    Range(A1, O35).Select
    ActiveWindow.Zoom
    End Sub</font color=blue>

    What am I missing? Maybe I need to put the statements into the ThisWorkBook object?
    - Ricky

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Compile error: (XL2000 SR-1)

    Ricky, your first line needs quotes around the cell addresses

    Range("A1", "O35").Select

    I'm not familiar with the "Zoom" property, but it definitely needs a percent setting, such as

    ActiveWindow.Zoom = 80

    If you want to show only the selected range you may also want to use:

    ActiveWindow.View = xlPageBreakPreview

    before setting ActiveWindow.Zoom
    -John ... I float in liquid gardens
    UTC -7ąDS

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Compile error: (XL2000 SR-1)

    Ricky,

    try <pre>Private Sub Worksheet_Activate()
    Range("A1:O35").Select
    ActiveWindow.Zoom = True
    End Sub</pre>


    John,

    ActiveWindow.Zoom = True will zoom to the selection, useful if you do not know in advance of the screen resolution a user might be using and so cannot specify a % factor.

    Andrew C

  4. #4
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Compile error: (XL2000 SR-1)

    Thanks for the explanation on Zoom. <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15> Wasn't apparent in 97 Help.
    -John ... I float in liquid gardens
    UTC -7ąDS

Posting Permissions

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