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

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
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,215,339
Messages
6,124,365
Members
449,155
Latest member
ravioli44

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