I was wondering what is causing Run-time error 1004 for this macro when I run it:
Sub brand()
'
' brand Macro
'
' Keyboard Shortcut: Ctrl+Shift+B
'
Range("M1").Select
ActiveCell.FormulaR1C1 = "Brand"
Range("M2").Select
ActiveCell.FormulaR1C1 = _
"=IF(OR(ISNUMBER(SEARCH(""trident"", RC[-12]))), ""Trident"", IF(OR(ISNUMBER(SEARCH(""stride"", RC[-12]))),""Stride"", IF(OR(ISNUMBER(SEARCH(""mints"", RC[-12]))), ""Mints"", IF(OR(ISNUMBER(SEARCH(""gum bubb"", RC[-12]))), ""Gum Bubb"", IF(OR(ISNUMBER(SEARCH(""gum heritage"", RC[-12]))), ""Gum Heritage"", IF(OR(ISNUMBER(SEARCH(""dentyne"", RC[-12]))), ""Dentyne"", IF" & _
"MBER(SEARCH(""candy struble"", RC[-12]))), ""Candy Struble"", IF(OR(ISNUMBER(SEARCH(""halls struble"", RC[-12]))), ""Halls"", ""Other""))))))))"
Range("M2").Select
Selection.AutoFill Destination:=Range("M2:M525998")
Range("M2:M525998").Select
Range("O8").Select
End Sub
I had a similar macro which actually did work when I run the macro:
Sub location()
'
' location Macro
' fill in location
'
' Keyboard Shortcut: Ctrl+Shift+L
'
Range("L1").Select
ActiveCell.FormulaR1C1 = "Location"
Range("L2").Select
ActiveCell.FormulaR1C1 = _
" =IF(OR(ISNUMBER(SEARCH(""ontario"",G4))),""Ontario"", IF(OR(ISNUMBER(SEARCH(""carlisle"",G4))),""Carlisle"",IF(OR(ISNUMBER(SEARCH(""orchard"",G4))),""Orchard"",""Other""))) "
Range("L2").Select
ActiveCell.FormulaR1C1 = _
"=IF(OR(ISNUMBER(SEARCH(""ontario"",R[2]C[-5]))),""Ontario"",IF(OR(ISNUMBER(SEARCH(""carlisle"",R[2]C[-5]))),""Carlisle"",IF(OR(ISNUMBER(SEARCH(""orchard"",R[2]C[-5]))),""Orchard"",""Other"")))"
Range("L2").Select
Selection.AutoFill Destination:=Range("L2:L425682")
Range("L2:L425682").Select
Range("N3").Select
End Sub
Both of these macros where created by recording them and for both I did the same process (the brand macro has a bigger formula). But for some reason the brand macro has run-time error, while the location macro does not. I am new to excel so I was wondering if anyone knows how I can fix it. Thank you.
IFMBER. - user4039065