Looping through all rows in a table column, Excel-VBA

前端 未结 9 565
予麋鹿
予麋鹿 2020-12-14 19:12

I\'m currently working on a data set which is formatted as a table, with headers. What I need to do is cycle through all cells in a specific column and change the contents.

9条回答
  •  伪装坚强ぢ
    2020-12-14 20:01

    You can search column before assignments:

    Dim col_n as long
    for i = 1 to NumCols
        if Cells(1, i).Value = "column header you are looking for" Then col_n = i
    next
    
    for i = 1 to NumRows
        Cells(i, col_n).Value = "PHEV"
    next i
    

提交回复
热议问题