LastLine

When visiting Anne-Marie at St Soline we practiced VBA with a simple Excel problem: Select the last Cell of a sheet.

Anne-Marie sometimes use Excel to log events. She often just type a row and quit going down to the last line is quite a loss of time.

We finished with this macro which is quite complicated but resistant to holes in an Excel sheet.


Sub LastLine()
    Dim ici As Range
    Dim verif As Range
    Set ici = Range("A1")
    Set verif = ici
    While (verif.Row < ici.Offset(100, 0).Row)
      Set ici = verif
      While (ici.Formula <> "")
           Set ici = ici.Offset(1, 0)
      Wend
       'Check the next 100 cells for any content.
       Set verif = ici
       While (verif.Formula = "" And verif.Row < ici.Offset(100, 0).Row)
            Set verif = verif.Offset(1, 0)
        Wend
    Wend
    ici.Select
End Sub

No Comments to “LastLine”  

  1. No Comments

Leave a Reply