|Excel And SQL .com|
Home > VBA Macros
How can I find last row that contains data in a column
The latest versions of excel now allows to have more than a million rows and 1048576 rows and columns all the way up XFD thats 16384 columns. Thats a lot of cells in deal with.
When you are processing data in using loop structures like for and while, it would be efficient to process only rows and columns only upto the last row or column that has data.
So to get the last row that has data in a certail column like B, you can use below statement to find the last row that has data.
Sub Demo() Dim ColumnToLookFor As String ColumnToLookFor = "B" lngLastRow = Cells(Rows.Count, ColumnToLookFor).End(xlUp).Row MsgBox "Last Row is" & lngLastRow End Sub
|© All Rights Reserved. ExcelAndSql.com|