How to get the address of the last not empty cell in excel using MACROS (VBA)

I want to get the cell address of the last non empty cell inside an excel sheet. Basically I want the row and column number / name of the last non-empty cell. I found several ansers to find out the value in the last non-empty cell, but I need a cell address that does not contain.

+3


source to share


1 answer


For data of type:

xsdew

Most people would like to find Blue Cell:



Sub FindBlue()
    Dim rng As Range
    Set rng = Cells.Find(What:="*", After:=Cells(1), SearchDirection:=xlPrevious, searchorder:=xlByRows)
    MsgBox rng.Address(0, 0)
End Sub

      

If you want a Yellow Cell then:

Sub FindYellow()
    Dim rng As Range
    Set rng = Cells.Find(What:="*", After:=Cells(1), SearchDirection:=xlPrevious, searchorder:=xlByColumns)
    MsgBox rng.Address(0, 0)
End Sub

      

+3


source







All Articles