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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,214,988
Messages
6,122,620
Members
449,092
Latest member
amyap

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