ItalianPlatinum
Well-known Member
- Joined
- Mar 23, 2017
- Messages
- 880
- Office Version
- 365
- 2019
- Platform
- Windows
I am looking to evaluate all of column AQ starting on row 11 until the last row if there are any Yes. I want to skip a section of code if there are no "Yes" so trying to do this but getting object variable error. What part am I missing?
VBA Code:
'copy formulas down
With Sheets("ALL")
lr = .Cells(rows.count, "A").End(xlUp).row
.Range("AN11:AN" & lr).Formula = "=ROUND(H11-SUM(I11:K11),2)"
.Range("AO11:AO" & lr).Formula = "=SUM(M11:P11)"
.Range("AP11:AP" & lr).Formula = "=SUM(Q11:AL11)"
.Range("AQ11:AQ" & lr).Formula = "=IF(AND(AN11=0,AO11=0,AP11=0),""No"",""Yes"")"
.Range("AN11:AQ" & lr).Value = .Range("AN11:AQ" & lr).Value
Set rng = .Range("AQ11:AQ" & lr)
End With
'Evaluate if any YES if exist then transfer data over
If Application.WorksheetFunction.CountIf(Range(rng), "Yes") > 0 Then
'Rest OF CODE here