Zoom auto select and and copy

polska2180

Active Member
Joined
Oct 1, 2004
Messages
384
Office Version
  1. 365
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
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
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 ]
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0
- 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!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top