Hey all, I must be missing something really simple, I am trying to enter a formula to populate department names for their counterpart number and I keep encountering errors, the debug is highlighting the formula but I can't figure out what I am doing wrong:
Sub AutoFillFormula()
Sheets("excads").Select
With ActiveSheet
LastR = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
ActiveSheet.Range("O3").FormulaR1C1 = _
"=(IF(RC[-2]=1,""Grocery"",IF(RC[-2]=2,""Deli"",IF(RC[-2]=3,""Grocery"",IF(RC[-2]=4,""Vitamins"",IF(RC[-2]=5,""Vitamins"",IF(RC[-2]=6,""Grocery"",IF(RC[-2]=7,""Grocery"",IF(RC[-2]=8,""Vitamins"",IF(RC[-2]=9,""Grocery"",IF(RC[-2]=10,""Grocery"",IF(RC[-2]=11,""Grocery"",IF(RC[-2]=12,""Produce"",IF(RC[-2]=13,""Meat"",IF(RC[-2]=14,""Grocery"",IF(RC[-2]=15,""Vitamins"",IF" & _
"16,""Beer&Wine"",IF(RC[-2]=17,""Deli"",IF(RC[-2]=18,""Bakery"",IF(RC[-2]=19,""Sushi"",IF(RC[-2]=20,""Floral"",IF(RC[-2]=22,""Juice Bar"",IF(RC[-2]=23,""Juice Bar"",IF(RC[-2]=24,""Bakery"",IF(RC[-2]=25,""Juice Bar"",IF(RC[-2]=36,""Meat"",IF(RC[-2]=37,""Meat"",IF(RC[-2]=86,""Urban Remedy"",""""))))))))))))))))))))))))))))"
ActiveSheet.Range("O3").AutoFill Destination:=ActiveSheet.Range("O3:O" & LastR)
End With
End Sub
Sub AutoFillFormula()
Sheets("excads").Select
With ActiveSheet
LastR = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
ActiveSheet.Range("O3").FormulaR1C1 = _
"=(IF(RC[-2]=1,""Grocery"",IF(RC[-2]=2,""Deli"",IF(RC[-2]=3,""Grocery"",IF(RC[-2]=4,""Vitamins"",IF(RC[-2]=5,""Vitamins"",IF(RC[-2]=6,""Grocery"",IF(RC[-2]=7,""Grocery"",IF(RC[-2]=8,""Vitamins"",IF(RC[-2]=9,""Grocery"",IF(RC[-2]=10,""Grocery"",IF(RC[-2]=11,""Grocery"",IF(RC[-2]=12,""Produce"",IF(RC[-2]=13,""Meat"",IF(RC[-2]=14,""Grocery"",IF(RC[-2]=15,""Vitamins"",IF" & _
"16,""Beer&Wine"",IF(RC[-2]=17,""Deli"",IF(RC[-2]=18,""Bakery"",IF(RC[-2]=19,""Sushi"",IF(RC[-2]=20,""Floral"",IF(RC[-2]=22,""Juice Bar"",IF(RC[-2]=23,""Juice Bar"",IF(RC[-2]=24,""Bakery"",IF(RC[-2]=25,""Juice Bar"",IF(RC[-2]=36,""Meat"",IF(RC[-2]=37,""Meat"",IF(RC[-2]=86,""Urban Remedy"",""""))))))))))))))))))))))))))))"
ActiveSheet.Range("O3").AutoFill Destination:=ActiveSheet.Range("O3:O" & LastR)
End With
End Sub