ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   End(XlDown).Row - Problem if only 1 row (https://www.excelbanter.com/excel-programming/397357-end-xldown-row-problem-if-only-1-row.html)

Ed Peters

End(XlDown).Row - Problem if only 1 row
 
Hi all,

I use the End(xldown).Row for splitting up a a file on import.

With ActiveSheet
LastCell8 = .Range("h1").End(xlDown).Row

.Range("m1").Copy
.Range("m2:m" & LastCell8).Select
.Paste
End With

However sometimes the import file is only 1 row and it ends up
selecting all 65,000 rows ...

Any thoughts how I can work this out bearing in mind I've already
written code using the above.

Thanks.

Ed


RB Smissaert

End(XlDown).Row - Problem if only 1 row
 
Use something like Cells(8, 65536).End(xlUp).Row

RBS


"Ed Peters" wrote in message
oups.com...
Hi all,

I use the End(xldown).Row for splitting up a a file on import.

With ActiveSheet
LastCell8 = .Range("h1").End(xlDown).Row

.Range("m1").Copy
.Range("m2:m" & LastCell8).Select
.Paste
End With

However sometimes the import file is only 1 row and it ends up
selecting all 65,000 rows ...

Any thoughts how I can work this out bearing in mind I've already
written code using the above.

Thanks.

Ed



David Hilberg

End(XlDown).Row - Problem if only 1 row
 
Substitute this line:

lastcell8 = .Range("h1").End(xlDown).End(xlDown).End(xlUp).Row

- David

On Sep 12, 3:44 pm, Ed Peters wrote:
Hi all,

I use the End(xldown).Row for splitting up a a file on import.

With ActiveSheet
LastCell8 = .Range("h1").End(xlDown).Row

.Range("m1").Copy
.Range("m2:m" & LastCell8).Select
.Paste
End With

However sometimes the import file is only 1 row and it ends up
selecting all 65,000 rows ...

Any thoughts how I can work this out bearing in mind I've already
written code using the above.

Thanks.

Ed





All times are GMT +1. The time now is 12:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com