Basically I want to change this:

=IF(B2<>C2,SUMIF($B$2:B2,B2,$B$1:B1),"")

Into a working version of something like this:

For z = 6 To LastCol

Cells(X3, z).Formula = "=IF(FX2<>GX2,SUMIf($F$X2:FX2,FX2,$F$X1:FX1),"")"

Next z

Where X3 is the cell into which the formula goes, X2 and X1 are variables of row number.

Thanks.