Forum Discussion

chahine's avatar
chahine
Iron Contributor
Jan 26, 2022
Solved

vba cells

hello i have a question, like i want to find last row number in a used range so when i use this code Debug.Print ActiveSheet.UsedRange.Cells(rows.count, 5).End(xlUp).Row   it gives an error, alth...
  • JMB17's avatar
    Jan 26, 2022
    Range references are relative, so if your data is in A17:D30, then that is your usedrange. So, 1048576 rows down from row 17 is beyond excel's row limit and you'll get an error.

    Try: ActiveSheet.Cells(rows.count, 5).End(xlUp).Row

Resources