PDA

View Full Version : Problem with code



ads_3131
08-04-2011, 12:48 AM
Hi all

i have 3 sheets , each row has a button in sheet guardshop & guardshop1 which when clicked copies the data in a specific range and pastes it in sheet 3 under the last bit of data copied.......

the below code works if you keep clicking in guardshop or guardshop1 but as soon as you click in into another sheet and run it, it replaces the last entry :/

code below
....................................................

Sub btn1()

' Macro recorded 03/08/2011 by P255

Range("F24:L27,M25:M26,P24:S27,T24:T26,V24:V26,U24:IJ26").Select

Range("G24:U27").Select

Selection.Copy

Call Archive

Sheets("GuardShop").Select
Range("F24:L27,M25:M26,P24:S27,T24:T26,V24:V26,U24:IJ26").Select
Selection.ClearContents

End Sub
....................................................................

The Call Archive Code is below
...................................................................

Sub Archive()

Sheets("Archive").Select
Range("C" & Cells.Rows.Count).End(xlUp).Offset(1).Select
ActiveSheet.Paste

End Sub
..................................................................

The code for buttons on sheet two are the same but instead of
Sheets("GuardShop").Select it is
Sheets("GuardShop1").Select

any help would be great :)

Bob Phillips
08-04-2011, 03:42 AM
I think the code can be tidied up, but what other sheet?



Sub btn1()

' Macro recorded 03/08/2011 by P255

Range("G24:U27").Copy

Call Archive

Sheets("GuardShop").Range("F24:L27,M25:M26,P24:S27,T24:T26,V24:V26,U24:IJ26"). ClearContents

End Sub

Sub Archive()

Sheets("Archive").Range("C" & Cells.Rows.Count).End(xlUp).Offset(1).Paste

End Sub