PDA

View Full Version : Solved: Solved Zoom in if specific cells are selected



KarlV
05-20-2009, 08:09 AM
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?



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

Kenneth Hobs
05-20-2009, 08:28 AM
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

KarlV
05-20-2009, 08:33 AM
Thank you very much.

mdmackillop
05-20-2009, 12:22 PM
Hi Karl,
Welcome to VBAX.
FYI, you mark questions solved here using the Thread Tools dopdown.
Regards
MD