Dear friends,
Please help me how to Add formula through vba in the attached file on Column K.
I add Joint formula of COUNTIF and SUMIF to calculate amount of Column J in the attached file.
Thanking you
Imran
My code is here
Sub formula()
Dim Cell As Range
Dim rng1 as string
Dim rng2 as string
Dim rng3 as string
rng1 = "=IF("
rng2 = "COUNTIF($A$2:A2,A2)=1,"
rng3 = "SUMIF($A:$A,A2,$J:$J),"")""
For Each Cell In Range("K2:K" & Cells(Rows.Count, "A").End(xlUp).Row)
Cell.Formula = rng1 & rng2 &rng3
End If
Next Cell
End Sub
Bookmarks