I have an excel macro that applies values in Columns O, P, Q, R. It works fine for Column O, but for Column P, Q & R, the values keep getting applied even though there is a blank cell/blank row. What I would like is for the cells highlighted in red (see attached image), that the excel macro doesnt apply the formulas in those cells. How would I fix this? Thanks
VBA Code:
Sub ResetFormulaOnBlankRow()
Dim ws As Worksheet
Dim lastRow As Long
Dim i As Long
Dim denominator As Double
Dim FRow As Long
Set ws = ThisWorkbook.Sheets("Sheet1") ' Change the sheet name as needed
lastRow = ws.Cells(ws.Rows.Count, "H").End(xlUp).Row
FRow = 3
For i = 3 To lastRow
If ws.Cells(i, 1).Value = "" Then
denominator = ws.Cells(i, 4).Value
FRow = i + 1
Else
ws.Cells(i, 15).Formula = "=" & "H" & i & "/" & "$D$" & FRow
ws.Cells(i + 1, 16).Formula = "=" & "H" & i + 1 & "/" & "$D$" & FRow + 1
ws.Cells(i + 2, 17).Formula = "=" & "H" & i + 2 & "/" & "$D$" & FRow + 2
ws.Cells(i + 3, 18).Formula = "=" & "H" & i + 3 & "/" & "$D$" & FRow + 3
End If
Next i
End Sub