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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi. Try

Code:
Sub test()
Range("A" & Rows.Count).End(xlUp).EntireRow.Copy Destination:=Sheets("Sheet2").Range("A1")
End Sub
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,504
Messages
6,114,016
Members
448,543
Latest member
MartinLarkin

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