Run-time error '1004' Application-defined or object defined error

carnut041

New Member
Joined
Mar 6, 2017
Messages
4
Hi. I am having an issue with a macro I wrote that reformats a report I receive in Excel. One of the commands looks for the blank cells in column A and based on the content of column C, enters the appropriate value. Frequently, when I run the macro I get "Run-time error '1004' Application-defined or object defined error" and when I click on Debug, it highlights the blue line of code:

Columns("A:A").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.FormulaR1C1 = _
"=+IF(ISNUMBER(SEARCH(""CSC"",RC[2])),""Phn-Dsk"",IF(RC[2]=""TGR1"",""TGR1"",IF(RC[2]=""EST-A"",""TRP"",IF(RC[2]=""EST-D"",""TRP"",IF(RC[2]=""1154"",""Phn-Dsk"",IF(RC[2]=""1164"",""Phn-Dsk"",IF(RC[2]=""5"",""Phn-Dsk"",IF(RC[2]=""10"",""Phn-Dsk"",IF(RC[2]=""11"",""Phn-Dsk"",IF(RC[2]=""13"",""Phone-Desk"",""ERROR""))))))))))"

The odd thing is that it doesn't error every time. It's almost like if you try enough times, eventually it gives in and runs through. I have tried breaking the statement down into individual IF/THEN statements, but it doesn't work. In that case, even through I said to leave the field blank if it didn't meet the criteria, it pastes in the formula.

Any idea why I am getting the error message and how I can work around it? I would appreciate any help you can give. Thank you.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,216,075
Messages
6,128,665
Members
449,462
Latest member
Chislobog

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top