Consulting

Results 1 to 4 of 4

Thread: Solved: Solved Zoom in if specific cells are selected

  1. #1
    VBAX Newbie
    Joined
    May 2009
    Posts
    2
    Location

    Solved: Solved Zoom in if specific cells are selected

    Hi,

    I've this code for zooming if cell D8 is selected. Cell D8 is a merged cell with data validation (dropdownlist). For some reason the code doesn't seem to work. If I choose an unmerged cell it seems to work alright. Please can anyone tell me what I'm doing wrong?



    [VBA]Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Address = "$D$8" Then
    ActiveWindow.Zoom = 125
    Else
    ActiveWindow.Zoom = 100
    End If
    End Sub
    [/VBA]
    Last edited by KarlV; 05-20-2009 at 01:15 PM. Reason: Solved

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    [VBA]Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim r As Range
    Set r = Intersect(Target, Range("D8"))
    If r Is Nothing Then
    ActiveWindow.Zoom = 100
    Else: ActiveWindow.Zoom = 125
    End If
    End Sub[/VBA]

  3. #3
    VBAX Newbie
    Joined
    May 2009
    Posts
    2
    Location
    Thank you very much.

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Karl,
    Welcome to VBAX.
    FYI, you mark questions solved here using the Thread Tools dopdown.
    Regards
    MD
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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