Moving a range between sheets

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I'm using Excel 2003 and am trying to move a range from one sheet to another using VBA, but I am not having a great deal of luck. In a macro I can perform what I want with this code

Sheets("Customers").Select
Range("A16:I16").Select
Selection.Copy
Sheets("CheckIn").Select
Range("A5").Select
Selection.Paste

However I wish to do this by attaching code to the click event of a button rather than a macro, using the code from the Macro in the click event will bring up a runtime error 1004 'Select method of range class failed', the problem seems to be on the Range("A16:I16").Select line. Running the Macro works fine and the data is copied over.

Thanks for any information
Jack
 
Jack said:
However I wish to do this by attaching code to the click event of a button rather than a macro,
using the code from the Macro in the click event will bring up a runtime error 1004
'Select method of range class failed',

Set the TakeFocusOnClick property of the button to False


Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup
 
Back
Top