Lartk
11-19-2012, 10:41 AM
How can I make it so this code only runs IF cell A9 has a date in it? If cell A9 is blank, then I would like to not run this code because an error occurs.
Sub BlockQuantityfidelity()
Const FORMULA_SUM As String = _
"=IF($G9="""","""",SUMPRODUCT(--($G$9:$G$<lastrow>=$G9),--($H$9:$H$<lastrow>=$H9),$AN$9:$AN$<lastrow>))"
Dim lastrow As Long
With ActiveSheet
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("AC9").Resize(lastrow - 8).Formula = Replace(FORMULA_SUM, "<lastrow>", lastrow)
End With
End Sub
Sub BlockQuantityfidelity()
Const FORMULA_SUM As String = _
"=IF($G9="""","""",SUMPRODUCT(--($G$9:$G$<lastrow>=$G9),--($H$9:$H$<lastrow>=$H9),$AN$9:$AN$<lastrow>))"
Dim lastrow As Long
With ActiveSheet
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("AC9").Resize(lastrow - 8).Formula = Replace(FORMULA_SUM, "<lastrow>", lastrow)
End With
End Sub