I'm trying to: (1) select a cell, (2) paste in a formula, (3) copy down the formula without it converting itself into something unusable.
I've seen this happen once before but forgot why it occurs and what to do to prevent it from happening again.
Here's the function within my small test file:
=SUMIF(INVENTORY!$C$2:$C$5,PARTS!B2,INVENTORY!$A$2:$A$5)
It converts itself to:
=SUMIF(INVENTORY!$C$2:$C$5,PARTS!XFD2,INVENTORY!$A$2:$A$5)

Here's the code I'm trying to utilize, where the formula gets trashed out - but if anyone has better ideas - I'm open to suggestions!
Sub PasteFormulaCopyDown()
'
Range("C2").Select
ActiveCell.FormulaR1C1 = _
"=SUMIF(INVENTORY!R2C3:R5C3,PARTS!RC[-3],INVENTORY!R2C1:R5C1)"
Range("C2").Select
Range("C2").FormulaR1C1 = "=SUMIF(INVENTORY!R2C3:R5C3,PARTS!RC[-3],INVENTORY!R2C1:R5C1)"
Range("C2:C2").AutoFill Destination:=Range("C2:C" & Range("A" & Rows.Count).End(xlUp).Row), Type:=xlFillDefault
Range("C2").AutoFill Destination:=Range("C2:C" & Range("A" & Rows.Count).End(xlUp).Row), Type:=xlFillValues
End Sub
Bookmarks