Help with existing code

Malcolm torishi

Board Regular
Joined
Apr 26, 2013
Messages
219
Hi can anyone please help I have the following VBA Code that works great but what I know would like to do is rather than the code copy the first 4 cells on a row when I double click, let’s say cells A1-A4, can the code not touch and leave cell A3 alone . So even if I was to modify the code below to copy more cells say A1-A10 it would always leave Cell A3 alone
thank anyone you can help

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified 6/18/2019 2:29:06 PM EDT
If Target.Column = 5 And Target.Row > 1 Then
Cancel = True
Dim Lastrow As Long
Lastrow = Sheets(2).Cells(Rows.Count, "A").End(xlUp).Row + 1
Target.Offset(, -4).Resize(, 4).Copy Sheets(2).Cells(Lastrow, 1)
End If
End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
not sure but can you hide that row in the code when run and then unhide after. It happens often to me manually when I select filtered data ?
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

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