Showing posts with label last row. Show all posts
Showing posts with label last row. Show all posts

Monday, 7 May 2012

Excel VBA Macro - Determine Last Row

Determining last row in Macro is one of the most important thing that you need to know for any loop to work.
I will share with you some ways to do it


Example 1: lastrow = Cells(Rows.Count, 1).End(xlUp).Row

Example 2: lastrow = Worksheets("anyname").UsedRange.Rows.Count

Personally I prefer to use method in example 1, this is because I can specify the column in the cells section to use to determine the last row. This allows for some flexibility:)