Excel vba macro find last row. It is just like going to last row in sheet and then pressing ctrlup shortcut. I look forward to reading about your experiences. You could then use the last row variable in the macro in place of the row number for example range a1f lastrowselect the above code would select my table a1 f and the final row. Find last cell vba examplexlsm 796 kb to find the last used row in a column this technique starts at the last cell in the column and goes up xlup until it finds the first non blank cell.
Excel vba last row finding the last row in a column is an important aspect in writing macros and making those dynamic. Also if you can think of any other ways to use vba code to find the last row or last column post your coding method in the comments section so we can improve the current list. We will use the same method in vba too to find the last row. It will take us to the last used row before any empty cell.
Before i explain to you the code i want you to remember how you go to the last row in the normal worksheet. This part selects cell in column a. To get the last row with data in a worksheet we need to use the specialcells or find properties of an excel vba range. After that enter a dot to get the list of properties and methods.
As we would not prefer to update the cell ranges every now and then when we are working with excel cell references. The rowscount statement returns a count of all the rows in the worksheet. Dim lastrow as range ws as worksheet set ws activesheet get last row with data in worksheet using specialcells debugprint wscellsspecialcellsxlcelltypelastcellrow set lastrow wscellsspecialcellsxlcelltypelastcellentirerow. Select or type end and enter a starting parenthese.
Last used row with data in worksheet.