Copy and paste a row of data based on the location of the active celll

sncr137

New Member
Joined
Nov 14, 2015
Messages
26
Hello Everyone,

I am in need of a macro that, upon a double click, copies the data in a row based on the active cell being located somewhere on that row. Once Copied I would like it to paste the selected row into the next sheet in the next empty row.

The first row is D1 to J1 and then goes down from there. If I select D1 or J1 I would like it to copy the data from D1 to J1. Then Paste that data to the next sheet in the next available cell starting in B3.

I am very much a beginner and need some community help. Thank You.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Rich (BB code):
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Dim LR As Long
    If Not Intersect(Target, Range(Cells(Target.Row, "D"), Cells(Target.Row, "J"))) Is Nothing Then
        LR = Sheets("Shopping Cart").Range("B" & Rows.Count).End(xlUp).Row
        If LR < 2 Then LR = 2
        With Intersect(Rows(Target.Row), Columns("d:j"))
            Sheets("Shopping Cart").Range("B" & LR).Offset(1).Resize(.Rows.Count, .Columns.Count).Value = .Value
        End With
    End If
End Sub

or

Rich (BB code):
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Dim LR As Long
    If Not Intersect(Target, Range(Cells(Target.Row, "D"), Cells(Target.Row, "J"))) Is Nothing Then
        LR = Sheets("Shopping Cart").Range("B" & Rows.Count).End(xlUp).Row
        If LR < 2 Then LR = 2
        Intersect(Rows(Target.Row), Columns("d:j")).Copy
            Sheets("Shopping Cart").Range("B" & LR).Offset(1).PasteSpecial xlPasteValues
    End If
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
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