Iterating through all the cells in Excel VBA or VSTO 2005

后端 未结 9 1604
既然无缘
既然无缘 2020-12-03 07:15

I need to simply go through all the cells in a Excel Spreadsheet and check the values in the cells. The cells may contain text, numbers or be blank. I am not very familiar

9条回答
  •  春和景丽
    2020-12-03 07:56

    If you're just looking at values of cells you can store the values in an array of variant type. It seems that getting the value of an element in an array can be much faster than interacting with Excel, so you can see some difference in performance using an array of all cell values compared to repeatedly getting single cells.

    Dim ValArray as Variant
    ValArray = Range("A1:IV" & Rows.Count).Value
    

    Then you can get a cell value just by checking ValArray( row , column )

提交回复
热议问题