Trying to fix my spreadsheet to paste a formula in column N, based on the value of column A. Essentially, if cell A6 = "Text 1" then cell N6 = "Formula 1", if cell A7 = "Text 2" then cell N7 = "Formula 2" then have this loop through all rows.
Very amateur at VBA, so excessive googling has given me the below.
Sub Test()
lr = Cells.Find("*", Cells(1, 1), xlFormulas, xlPart, xlByRows, xlPrevious, False).Row
For Each Cell In Range("A6:A" & lr)
If Cell.Value = "Call Options" Then
Cell.Offset(0, 13).Value = "=-(B6*100)*E6"
ElseIf Cell.Value = "Put Options" Then
Cell.Offset(0, 13).Value = "=(B6*100)*E6"
End If
Next Cell
End Sub
Any help would be much appreciated.
Aucun commentaire:
Enregistrer un commentaire