ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do I dynamically retrieve the cell address of the last cell t. (https://www.excelbanter.com/excel-discussion-misc-queries/2228-how-do-i-dynamically-retrieve-cell-address-last-cell-t.html)

Nancy

How do I dynamically retrieve the cell address of the last cell t.
 
I want to write to an excel file that already has data in it using matlab
xlswrite function. I found that I can write to the excel file without
overwriting information that is already there. So I was wondering if there
is a way in excel to retrieve the address or index of the last cell
containing data.

Otto Moehrbach

Nancy
There are several ways of doing this depending on the layout of your
data.
Say you have data in all the cells of A1:A10. No blank cells in that
range. You can use:
LastCellAddress = Range("A1").End(xlDown).Address(0,0)
This will give the address of A10.

If you have blank cells in your data and you want to find the address of the
last occupied cell, use:
LastCellAddress = Range("A" & Rows.Count).End(xlUp).Address(0,0)
HTH Otto
"Nancy" wrote in message
...
I want to write to an excel file that already has data in it using matlab
xlswrite function. I found that I can write to the excel file without
overwriting information that is already there. So I was wondering if
there
is a way in excel to retrieve the address or index of the last cell
containing data.





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

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