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,296
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,296
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,516
Messages
5,340,873
Members
399,396
Latest member
PBE

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top