+ Reply to Thread
Results 1 to 4 of 4

How can I modify lzoom to return to previous magnification setting?

  1. #1
    Registered User
    Join Date
    12-19-2011
    Location
    Leeds
    MS-Off Ver
    Excel 2003
    Posts
    15

    How can I modify lzoom to return to previous magnification setting?

    Hi all,

    I need to modify the below code so the lzoom returns to the previous setting for the worksheet in question. I'd specify the number but I have another macro that changes the worksheet zoom based on the user's screen resolution so the figure will be different in each case. Can I not use lzoom = previous or default, or something similar?

    Thanks in advance...


    PHP Code: 
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
      
    Dim lZoom As Long
      Dim lZoomDV 
    As Long
      Dim lDVType 
    As Long
      lZoom 
    = [B]70[/B]
      
    lZoomDV 120
      lDVType 
    0

      Application
    .EnableEvents False
      On Error Resume Next
      lDVType 
    Target.Validation.Type
      
        On Error 
    GoTo errHandler
        
    If lDVType <> 3 Then
          With ActiveWindow
            
    If .Zoom <> lZoom Then
              
    .Zoom lZoom
            End 
    If
          
    End With
        
    Else
          
    With ActiveWindow
            
    If .Zoom <> lZoomDV Then
              
    .Zoom lZoomDV
            End 
    If
          
    End With
        End 
    If

    exitHandler:
      
    Application.EnableEvents True
      
    Exit Sub
    errHandler
    :
      GoTo 
    exitHandler
    End Sub 

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,971

    Re: How can I modify lzoom to return to previous magnification setting?

    Use a static variable and assign the original ActiveWindow.Zoom to it before you change it for your DV zoom. You can then test against that and change back if required, in the other section of the code.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    12-19-2011
    Location
    Leeds
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: How can I modify lzoom to return to previous magnification setting?

    Hi Romperstomper,

    My VBA skills are not great...could you possibly offer the code that will achieve that? Or an example of it.

    Thanks

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,971

    Re: How can I modify lzoom to return to previous magnification setting?

    You'll probably want to be able to set the level when the sheet is initially activated too, so:
    Please Login or Register  to view this content.

+ 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.6.0 RC 1