Formula or VBA?

ccameron

Board Regular
Joined
Jul 3, 2010
Messages
226
Hi Everyone,
I was wondering if someone could help? I have a table of data that I would like to copy the last 2 rows only to another sheet. The table range is 'Defect Total' A40:N79, each week the data is updated so I would like to use a formula or macro that will copy the last 2 rows and paste the data into sheet1 A1:N2. any suggetions would be great.
With the table below I would want to copy and paste A71:K72, the following week I would want A72:K73.
Excel Workbook
ABCDEFGHIJK
686/04/2011161402110021327445129654
6913/04/2011154802212021027438119640
7020/04/2011161402014019331443151651
714/05/2011146802414020631414146538
7211/05/2011139302312014831416145529
7318/05/2011
7425/05/2011
751/06/2011
Defects Total
Excel 2007



Thankyou
ccameron
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
I'm confused as to whether it is K or N. This is for K

Code:
Sub Cpy()
Dim LR As Long
With Sheets("Defect Total")
    LR = Range("B" & Rows.Count).End(xlUp).Row
    .Range("A" & LR - 1).Resize(2, 11).Copy Destination:=Sheets("Sheet1").Range("A1")
End With
End Sub
 
Upvote 0
Try

Rich (BB code):
Sub Cpy()
Dim LR As Long
With Sheets("Defect Total")
    LR = .Range("B" & Rows.Count).End(xlUp).Row
    .Range("A" & LR - 1).Resize(2, 14).Copy Destination:=Sheets("Sheet1").Range("A1")
End With
End Sub
 
Upvote 0
I would like to use a formula or macro
For a formula approach (this would have the advantage of automatically updating when a new row is added to the 'Defects Total' sheet) try this in A1 of Sheet1 and copy across to N1 and down to row 2. (You may subsequently need to format A1:A2 as Date)

=INDEX('Defects Total'!A:A,MATCH(9.99E+307,'Defects Total'!$B:$B)-2+ROWS(A$1:A1))
 
Upvote 0
Thanks Peter,
I have used the code Vog supplied and added a button on the sheet and assigned the macro. But I will have a look at yours it may come in handy anyway.

Thanks again,

ccameron
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,348
Members
452,907
Latest member
Roland Deschain

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