How do I dynamically retrieve the cell address of the last cell t.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top