I met a little problem when I use:
Count_line = ActiveSheet.UsedRange.Rows.Count
to count how many lines do I have in a worksheet. It can not give me the correct number. Can it be influenced by the format of the cells? Cause I've different coulour to highlight some important columns.
If you've got sime idea, please leave a comment. Thank you!
Asked
Active
Viewed 228 times
-1

Community
- 1
- 1

Hiddenllyy
- 179
- 13
1 Answers
1
UsedRange.Rows.Count is not a reliable way to pull the last row, as it doesn't account for empty rows at the start of your sheet. Assuming you are finding the last row with text in it, use the End method to find the row.

RGA
- 2,577
- 20
- 38
-
Thank you, I've tried to use `End` ans here is the code : `Worksheets(Array(1)).Select Range("A3").Select ActiveCell.End(xlDown).Select ligne_Data = Selection.Row`. Can I put them in one line? It seems a little bit long right now. – Hiddenllyy Jul 04 '16 at 14:18
-
1In general, selection can (and should) be avoided like the plague. That could be written simply as `ligne_Data = Worksheets(Array(1)).Range("A3").End(xlDown).Row` – RGA Jul 04 '16 at 14:23