Copy to last line (cel) of data

jaycee

Active Member
Joined
Jul 22, 2009
Messages
323
I am using Excel 2003.

I want to select and copy data using a macro but only want to select upto and including the last line of data,
could be one line could be 200 lines.

I am using the following at the moment.

Sub RangeSelect()
ActiveSheet.Range("a100:h100", ActiveSheet.Range("a100:h100").End(xlDown)).Select
Selection.Copy
End Sub

But this selects lines after the last line of data.

Any help would be great.
 

Some videos you may like

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Trevor G

Well-known Member
Joined
Jul 17, 2008
Messages
6,701
Office Version
  1. 2016
Platform
  1. Windows
What if you did it from the bottom and looked to select upwards.

HTML:
Sub Macro1()
'
' Macro1 Macro
'

'
    Range("A65000").Select
    Selection.End(xlUp).Select
    Range(Selection, Selection.End(xlUp)).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.Copy
End Sub
 

jaycee

Active Member
Joined
Jul 22, 2009
Messages
323
Hi Trevor

Many thanks for the reply, but it appears that my original works, as long as I have something in column A, which is what it is based on anyway.

Thanks
Jaycee
 

Watch MrExcel Video

Forum statistics

Threads
1,123,320
Messages
5,600,935
Members
414,417
Latest member
Nobu

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