column A has data like this (ie frequent blank cells):
HEADING <-- this is A1 kfdsl fdjgnm fdkj gdfkj 4353 fdjk <-- this is A9
I would like to be able to get the cell reference of the last cell that has data. So in the above example, I want to return: A9
I have tried this but it stops at the first blank cell (ie returning A4
)
numofrows = destsheet.Range("A2").End(xlDown).Row - 1
ROWS is useful if we wish to find out the number of rows in a range. The most basic formula used is =ROWS(rng). The function counted the number of rows and returned a numerical value as the result. When we gave the cell reference B6, it returned the result of 1 as only one reference was given.
I like this way:
ActiveSheet.UsedRange.Rows.Count
The same can be done with columns count. For me, always work. But, if you have data in another column, the code above will consider them too, because the code is looking for all cell range in the sheet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With