Row count where data exists

前端 未结 7 1659
广开言路
广开言路 2021-02-08 19:24

I need to count the total number of rows that have data. I want to be able to use this on multiple sheets with different amounts of data rows.

I cannot figure out gener

7条回答
  •  失恋的感觉
    2021-02-08 19:49

    Assuming that your Sheet1 is not necessary active you would need to use this improved code of yours:

    i = ActiveWorkbook.Worksheets("Sheet1").Range("A2" , Worksheets("Sheet1").Range("A2").End(xlDown)).Rows.Count
    

    Look into full worksheet reference for second argument for Range(arg1, arg2) which important in this situation.

提交回复
热议问题