Private Sub CommandButton1_Click()
Dim row As Integer, col As Integer
row = 1
col = 1
'column A contains name
'column B contains age
'select records with age=23 if record found apply formula B + 1 in column C
While Sheet1.Cells(row, col).Value <> ""
If CInt(Sheet1.Cells(row, col + 1).Value) = 23 Then
Sheet1.Cells(row, col + 2).Formula = "=B" & row & " + 1"
End If
row = row + 1
Wend
End Sub