Need Macro for last filled row

akash.scap

New Member
Joined
Feb 8, 2011
Messages
20
Hello, have information filled out in rows and columns from A4:k15
Information is usually filled row by row (going horizontally)
Basically i need a macro where it can select the last filled row
and copy it over to the sheet2 row 1 (should paste sheet2 row 1 every time)

Please help
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Hi. Try

Code:
Sub test()
Range("A" & Rows.Count).End(xlUp).EntireRow.Copy Destination:=Sheets("Sheet2").Range("A1")
End Sub
 

stefankemp

Board Regular
Joined
Mar 11, 2010
Messages
136
sub findpaste()
dim lastrow as long
dim col as long

with sheet1
for col = 1 to 11
if .cells(.rows.count,col).end(xlup).row > lastrow then
lastrow = .cells(.rows.count,col).end(xlup).row
end if
next col
end with

sheet2.range("A1:K1").value = sheet1.range(sheet1.cells(lastrow,1),sheet.cells _
(lastrow,11)).value

end sub
 

akash.scap

New Member
Joined
Feb 8, 2011
Messages
20

ADVERTISEMENT

One more question...

the information i have filled out is between A4 to K15 (sheet1) and keeps growing.

My limit row A40 (sheet1)

Is there was way for macro to only search A4 to A40 and then copy the last filled row in that range and then move to sheet 2 row1...basically it shouldn't pass A40 as i have other data underneath A40 on sheet 1
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try

Code:
Sub test()
Dim LR As Long
LR = WorksheetFunction.Min(40, Range("A" & Rows.Count).End(xlUp).Row)
Rows(LR).Copy Destination:=Sheets("Sheet2").Range("A1")
End Sub
 

Forum statistics

Threads
1,147,450
Messages
5,741,189
Members
423,647
Latest member
lyanndominique

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
Top