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

前端 未结 9 594
予麋鹿
予麋鹿 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 19:49

    You can find the last column of table and then fill the cell by looping throught it.

    Sub test()
        Dim lastCol As Long, i As Integer
        lastCol = Range("AZ1").End(xlToLeft).Column
            For i = 1 To lastCol
                Cells(1, i).Value = "PHEV"
            Next
    End Sub
    

提交回复
热议问题