Finding the last row in Excel

vba Australia
  • 18 years ago

    i have this loop running and it finds the last row. It is pretty slow is there a quicker way to find the last row with something in it.

    Code:

       'Variables used for finding out last row in worksheet.
       Dim blnContinue As Boolean
           
       'Finds out the last row in worksheet.
    '--Start Last Row--'


       'Set initial values
       blnContinue = False
       gintStartRow = 1
       
       'Code for finding last row
       Do While blnContinue <> True
           frmProgress.UpdateStatus
           If Worksheets("Isamastr").Cells.Range("A" & gintStartRow).value <> "" Then
               gintStartRow = gintStartRow + 1
           Else
               gintLastRow = gintStartRow - 1
               blnContinue = True
           End If
       Loop
    '--End Last Row--'

  • 18 years ago

    The following bit of code will find the last cell with something in it in the column below cell A1.


    Range("A1").End(xlDown).Select


    Works in Excel 2000, so you'll have to try it in Excel 97 to see if it works.

  • 18 years ago

    K thanks I'll give it a go.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“C++: an octopus made by nailing extra legs onto a dog.” - Steve Taylor