Edit: usedRows = Sheets("EFT").UsedRange.Count
To: usedRows = Sheets("EFT").Range("A" & Sheets("EFT").Rows.Count).End(xlUp).Row
Where "A" can be changed to any row you want to count, the total number of columns.
There is a danger of using UsedRange because it affects things like this and formatted cells without data and other things that can give unexpected results, for example, if you expect your data to start in Range ("A1"), but it really starts in another range!
I will say, however, that if you really want to use UsedRange , your code above is still wrong to get the lines. Use UsedRange.Rows.Count instead or, to get the last absolute cell of the range used, use UsedRange.SpecialCells(xlCellTypeLastCell).Row
source share