Command Button help

talt0612

New Member
Joined
Nov 22, 2011
Messages
35
I'm trying to copy/paste date from one range to another. The following code works fine for me until I assign it to a command button. When I assign it to a command button, I get the following error: Run-time error '1001': Method 'Range' of object '_Worksheet' failed

Any thoughts on how to fix this?

Code:
Private Sub CommandButton2_Click()
 Range("executionbox").Copy
  Sheets("tradehistory").Select
  Range("tradelist").End(xlDown).Offset(1, 0).Select
  ActiveSheet.Paste
  ActiveCell.Select
  ActiveCell.Value = Date
  Sheets("test2").Select
  Application.CutCopyMode = False
End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Try like this

Code:
Private Sub CommandButton2_Click()
Range("executionbox").Copy Destination:=Sheets("tradehistory").Range("tradelist").End(xlDown).Offset(1, 0)
End Sub

Where exactly do you want the date?
 
Upvote 0
Thanks VoG. That works perfectly. I'm trying to avoid using ".Select" as much as possible and this is a big help.
Regards,
T
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

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