vbaexcel

Last not empty cell (column) in the given row; Excel VBA


I have an excel sheet in which I need to find the last non empty cell in a specific row.

How do I do this?

The below will select this for me, but it will select the first not empty cell, I need the last not empty cell in the row #29.

Worksheets("DTCs").Range("A29").End(xlToRight).Select


Solution

  • I think it might work just search from the other direction, so something like:

    Worksheets("DTCs").Range("IV29").End(xlToLeft).Select
    

    Though maybe the IV would need to be changed to something else depending on the version of Excel (this seems to work in 2003).