13 Ocak 2017 Cuma

Excel VBA - Find the last row

In Excel VBA, we need to find out last row number (how many rows / data tables's rows count) to scroll down or other operations.

For example start from B2 to the last row in B column.

Sheets("FC").Range("b2").End(xlDown).Row

or

Sheets(1).Range("b2").End(xlDown).Row

Example: Read all row in the column and add to combo box.

For line= 2 To wb1.Sheets(1).Range("b2").End(xlDown).Row

ThisWorkbook.Sheets("Sheet1").ComboBox1.AddItem wb1.Sheets(1).Cells(satir, 2).Value

Next