I am trying to write vba code that completes this task on a range of cells with values: =IF(SUM(A2:B2)>0,"Yes","No")
but cannot get it to operate correctly. Here's what I have so far. Sorry I'm new to vba.
Sub formula3()
'formula3
On Error Resume Next
On Error GoTo 123:
Dim i As Long
Dim lastrow As Integer
Dim wsClient As Worksheet
Set wsClient = ThisWorkbook.Sheets("All P&C Client Data")
lastrow = wsClient.Cells.Find("*", wsClient.Range("F1"), xlFormulas, xlPart, xlByRows, xlPrevious, False).row
For i = 2 To lastrow
Sheet3.Range("t2").value = Application.WorksheetFunction.Sum(Sheet3.Cells(i, 1), Sheet3.Cells(i, 2))
Next
123:
value = "0"
Resume Next
lastrow = wsClient.Cells.Find("*", wsClient.Range("F1"), xlFormulas, xlPart, xlByRows, xlPrevious, False).row
For i = 2 To lastrow
If Sheet3.Cells(i, 20) > 0 Then
wsClient.Cells(i, 19) = "Yes"
Else
wsClient.Cells(i, 19) = "No"
End If
Next i
End Sub
Aucun commentaire:
Enregistrer un commentaire