I have a worksheet with a table that is constantly being updated, so the number of rows it has is variable. I am interested in retrieving the last value in column B
. However, the tricky part is that not all rows in this column of the table have a value. Sometimes the next cell with an actual value could be just below the previous one, and sometimes there could be many empty spaces in between.
I tried to use the following code to do so:
LastValue = Cells(Rows.Count, "B").End(xlUp).Value
The issue I am experiencing happens in a very specific scenario. If we suppose the last cell with a value in the column is B6
, but the last cell of the table corresponding to this column is B10
, the value retrieved is empty (the one in B10
). What I would need to find is cell B6
and give that value to the variable LastValue
. Is there any way to do this? I could only find code examples to find the last row of the entire worksheet, ignoring individual columns.