EXCEL VBA - Loop through cells in a column, if not empty, print cell value into another column

前端 未结 2 1255
失恋的感觉
失恋的感觉 2020-12-20 07:18

I\'m very new to Excel VBA and haven\'t quite familiarized myself with all the different functions and such, and I\'m quite sure I understand how to use IF statements within

2条回答
  •  無奈伤痛
    2020-12-20 07:45

    Assuming you have headers in row 1:

    Sub SO()
    
    Dim i As Long
    
    For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
        If LCase(Cells(i, 2).Value) = "yes" Then Range("D" & Rows.Count).End(xlUp).Offset(1, 0).Value = Cells(i, 1).Value
    Next i
    
    End Sub
    

提交回复
热议问题