find last used cell in columns

errtu

Board Regular
Joined
Sep 23, 2010
Messages
134
i need a macro to find the last line used (with data) in a range and paste the data of the whole line to cell O18.

Say I have range A13:K37 with data. So I need data from: A37, B37, C37, D37, E37, F37, G37, H37, I37, J37, K37 pasted to O13.

But the above is only an example, as it always changes it could be line 37 or it could be 15 or 20
 
I should have probably used HotPepper's method of determining the last row...

Code:
[FONT=Verdana][COLOR=darkblue]Option[/COLOR] [COLOR=darkblue]Explicit[/COLOR]

[COLOR=darkblue]Sub[/COLOR] test()

    [COLOR=darkblue]Dim[/COLOR] LastRow [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Long[/COLOR]

    LastRow = Cells(Rows.Count, "A").End(xlUp).Row
    
    Range(Cells(LastRow, "A"), Cells(LastRow, "K")).Copy Destination:=Range("O13")
    
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]
[/FONT]
this one seems to be working, thank you very much everyone
 
Upvote 0

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Are you wanting to do this on more than one sheet?

re:

Code provided by Domenic and Hotpepper was only for the active sheet.

Try this for All Sheets:
Code:
Sub test2()
    Dim ws As Worksheet
   Dim x As Long
For Each ws In ActiveWorkbook.Worksheets
    x = ws.Range("A" & Rows.Count).End(xlUp).Row
    ws.Range("A" & x).Resize(, 11).Copy ws.Range("O18")
 Next ws
 
End Sub
Every time you run it, it WILL erease what was in Row 18 Col O-Y. Is that what you wanted?

worked like a charm, i didnt see this one. its better all in one click than one by one. thank you my man!!:biggrin::biggrin::rofl:
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,866
Members
452,948
Latest member
UsmanAli786

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