Using macro as button instead of double click

sncr137

New Member
Joined
Nov 14, 2015
Messages
26
Someone kindly gave me the code below to use.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim LR As Long
If Not Intersect(Target, Range(Cells(Target.Row, "A"), Cells(Target.Row, "H"))) 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("a:h")).Copy Destination:=Sheets("Shopping Cart").Range("B" & LR).Offset(1)
End If
End Sub


I would like to use this on a button instead of a double click. Not sure how to begin.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
1. Create a shape
in excel 2007 onwards, find them on the Insert Tab, earlier versions, I think it is under the Insert menu
2. Right-click into the shape and select Assign macro - pick the macro name
3. optional...add text to your "button"
 
Upvote 0
The current code is copying cells that are in columns a:H of the row that you are double clicking on.

When you activate it by a button, how do you want to tell the routine which row's cells to copy?
 
Upvote 0
Honestly, I am not sure.

Where ever the active cell is in the list I would like, When I press the button, row (a:h) to be copied to the next available cell in sheet "Shopping cart.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,334
Members
452,636
Latest member
laura12345

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