Zoom auto select and and copy

polska2180

Active Member
Joined
Oct 1, 2004
Messages
345
Hi I currently have the following code that when I click on a pulldown menu it zooms in then when you clicks of zooms out.

What I want is to still zoom in but once I click on selection it zooms out and selects range B1:s10 and copys the selection.

I'm not sure if its possible to zoom out and the rest on selection, so the other option is once item is selected from the pulldown and clicked on another cell to zoom out (like it does now) then select the range and copy.

Thanks for the help.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)


On Error GoTo LZoom
Dim xZoom As Long
xZoom = 73

If Target.Validation.Type = xlValidateList Then xZoom = 130

LZoom:
ActiveWindow.Zoom = xZoom

End Sub
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
4,261
try adding this sub

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo LZoom
    Dim xZoom As Long
    xZoom = 73
    If Target.Validation.Type = xlValidateList Then
        With Range("B1:S10")
            .Select
            .Copy
        End With
    End If
LZoom:
    ActiveWindow.Zoom = xZoom
End Sub
Adding code tags formats code like you see it in a module. When posting code
- click on # icon above post window
[ CODE ] AND paste your code in between the code tags that appear [ /CODE ]
 

polska2180

Active Member
Joined
Oct 1, 2004
Messages
345
try adding this sub

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo LZoom
    Dim xZoom As Long
    xZoom = 73
    If Target.Validation.Type = xlValidateList Then
        With Range("B1:S10")
            .Select
            .Copy
        End With
    End If
LZoom:
    ActiveWindow.Zoom = xZoom
End Sub
Adding code tags formats code like you see it in a module. When posting code
- click on # icon above post window
[ CODE ] AND paste your code in between the code tags that appear [ /CODE ]
TY however now when I click on the cell A2 it no longer zooms in to 130%, it doesn't do anything.
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
4,261
now when I click on the cell A2 it no longer zooms in to 130%, it doesn't do anything
- the selection event was not changed by my code and should work exactly as it did before
- I tested and zoom to 130% occurs in A2 if it contains Data Validation

Your sheet module should now contain both these subs
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    On Error GoTo LZoom
    Dim xZoom As Long
    xZoom = 73
    If Target.Validation.Type = xlValidateList Then xZoom = 130
LZoom:
    ActiveWindow.Zoom = xZoom
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo LZoom
    Dim xZoom As Long
    xZoom = 73
    If Target.Validation.Type = xlValidateList Then
        With Range("B1:S10")
            .Select
            .Copy
        End With
    End If
LZoom:
    ActiveWindow.Zoom = xZoom
End Sub
 

polska2180

Active Member
Joined
Oct 1, 2004
Messages
345
- the selection event was not changed by my code and should work exactly as it did before
- I tested and zoom to 130% occurs in A2 if it contains Data Validation

Your sheet module should now contain both these subs
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    On Error GoTo LZoom
    Dim xZoom As Long
    xZoom = 73
    If Target.Validation.Type = xlValidateList Then xZoom = 130
LZoom:
    ActiveWindow.Zoom = xZoom
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo LZoom
    Dim xZoom As Long
    xZoom = 73
    If Target.Validation.Type = xlValidateList Then
        With Range("B1:S10")
            .Select
            .Copy
        End With
    End If
LZoom:
    ActiveWindow.Zoom = xZoom
End Sub
Ah, that is where I went wrong...TY works perfectly!
 

Forum statistics

Threads
1,078,240
Messages
5,339,031
Members
399,274
Latest member
WilliamWavehill

Some videos you may like

This Week's Hot Topics

Top