Help: Run-Time Error 1004 when running recorded macro!

darksider415

New Member
Joined
Mar 13, 2012
Messages
2
When running the following macro that I recorded, I'm getting an "Error 1004 Application-defined or object-defined error".

Code:
Sub Macro2()
'
' Macro2 Macro
'
' Keyboard Shortcut: Ctrl+q
'
    Windows("T054.xlsm").Activate
    Windows("T013").Activate
    Range("S10").Select
    Sheets("Sheet1").Select
    Range("S10").Select
    ActiveCell.FormulaR1C1 = _
        "=IF(OR(AND(OR(RC[-11]=10,RC[-11]=23,RC[-11]=22,RC[-11]=32,RC[-11]=29,RC[-11]=36,RC[-11]=33,RC[-11]=21,RC[-11]=38,RC[-11]=11,RC[-11]=19,RC[-11]=20,RC[-11]=17,RC[-11]=31,RC[-11]=26,RC[-11]=34,RC[-11]=28,RC[-11]=24,RC[-11]=32,RC[-11]=18,RC[-11]=22,RC[-11]=16,RC[-11]=30,RC[-11]=10,RC[-11]=10,RC[-11]=14,RC[-11]=37,RC[-11]=12,RC[-11]=39,RC[-11]=27,RC[-11]=12,RC[-11]=4,RC[" & _
        "C[-11]=6,RC[-11]=7,RC[-11]=25,RC[-11]=15,RC[-11]=5),RC[-11]=R[-8]C[-11],RC[-5]=0,RC[-4]=0,RC[-3]=0,RC[-2]=0,RC[-1]=0)),160,IF(AND(RC[2]=160,RC[-11]=28),319,IF(AND(RC[2]=160,RC[-11]=4),326,IF(AND(RC[2]=160,RC[-11]=2),310,IF(AND(RC[2]=160,RC[-11]=6),336,IF(AND(RC[2]=160,RC[-11]=7),348,IF(AND(RC[2]=160,RC[-11]=32),312,IF(AND(RC[2]=160,RC[-11]=21),343,IF(AND(RC[2]=160,R" & _
        "),312,IF(AND(RC[2]=160,RC[-11]=23),301,IF(AND(RC[2]=160,RC[-11]=10),319,IF(AND(RC[2]=160,RC[-11]=14),337,IF(AND(RC[2]=160,RC[-11]=29),328,IF(AND(RC[2]=160,RC[-11]=30),316,IF(AND(RC[2]=160,RC[-11]=27),302,IF(AND(RC[2]=160,RC[-11]=38),322,IF(AND(RC[2]=360,RC[-11]=12),314,IF(AND(RC[2]=160,RC[-11]=22),310,IF(AND(RC[2]=160,RC[-11]=22),326,IF(AND(RC[2]=160,RC[-11]=19),331" & _
        "C[2]=160,RC[-11]=39),311,IF(AND(RC[2]=160,RC[-11]=24),319,IF(AND(RC[2]=160,RC[-11]=26),312,IF(AND(RC[2]=160,RC[-11]=20),301,IF(AND(RC[2]=160,RC[-11]=34),306,IF(AND(RC[2]=160,RC[-11]=36),317,IF(AND(RC[2]=160,RC[-11]=12),317,IF(AND(RC[2]=160,RC[-11]=17),320,IF(AND(RC[2]=160,RC[-11]=18),301,IF(AND(RC[2]=160,RC[-11]=33),311,IF(AND(RC[2]=160,RC[-11]=16),333,IF(AND(RC[2]=" & _
        "1]=31),317,IF(AND(RC[2]=160,RC[-11]=37),309,IF(AND(RC[2]=160,RC[-11]=11),302,IF(AND(RC[2]=160,RC[-11]=10),333,IF(AND(RC[2]=160,RC[-11]=13),319,IF(AND(RC[2]=160,RC[-11]=15),314,IF(AND(RC[2]=160,RC[-11]=25),310,(IF(AND(RC[2]=160,RC[-11]=5),313,0))))))))))))))))))))))))))))))))))))))))"
    Range("S11").Select

I'm new to Excel, so any help would be greatly appreciated.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
When running the following macro that I recorded, I'm getting an "Error 1004 Application-defined or object-defined error".

Code:
Sub Macro2()
'
' Macro2 Macro
'
' Keyboard Shortcut: Ctrl+q
'
    Windows("T054.xlsm").Activate
    Windows("T013").Activate
    Range("S10").Select
    Sheets("Sheet1").Select
    Range("S10").Select
    ActiveCell.FormulaR1C1 = _
        "=IF(OR(AND(OR(RC[-11]=10,RC[-11]=23,RC[-11]=22,RC[-11]=32,RC[-11]=29,RC[-11]=36,RC[-11]=33,RC[-11]=21,RC[-11]=38,RC[-11]=11,RC[-11]=19,RC[-11]=20,RC[-11]=17,RC[-11]=31,RC[-11]=26,RC[-11]=34,RC[-11]=28,RC[-11]=24,RC[-11]=32,RC[-11]=18,RC[-11]=22,RC[-11]=16,RC[-11]=30,RC[-11]=10,RC[-11]=10,RC[-11]=14,RC[-11]=37,RC[-11]=12,RC[-11]=39,RC[-11]=27,RC[-11]=12,RC[-11]=4,RC[" & _
        "C[-11]=6,RC[-11]=7,RC[-11]=25,RC[-11]=15,RC[-11]=5),RC[-11]=R[-8]C[-11],RC[-5]=0,RC[-4]=0,RC[-3]=0,RC[-2]=0,RC[-1]=0)),160,IF(AND(RC[2]=160,RC[-11]=28),319,IF(AND(RC[2]=160,RC[-11]=4),326,IF(AND(RC[2]=160,RC[-11]=2),310,IF(AND(RC[2]=160,RC[-11]=6),336,IF(AND(RC[2]=160,RC[-11]=7),348,IF(AND(RC[2]=160,RC[-11]=32),312,IF(AND(RC[2]=160,RC[-11]=21),343,IF(AND(RC[2]=160,R" & _
        "),312,IF(AND(RC[2]=160,RC[-11]=23),301,IF(AND(RC[2]=160,RC[-11]=10),319,IF(AND(RC[2]=160,RC[-11]=14),337,IF(AND(RC[2]=160,RC[-11]=29),328,IF(AND(RC[2]=160,RC[-11]=30),316,IF(AND(RC[2]=160,RC[-11]=27),302,IF(AND(RC[2]=160,RC[-11]=38),322,IF(AND(RC[2]=360,RC[-11]=12),314,IF(AND(RC[2]=160,RC[-11]=22),310,IF(AND(RC[2]=160,RC[-11]=22),326,IF(AND(RC[2]=160,RC[-11]=19),331" & _
        "C[2]=160,RC[-11]=39),311,IF(AND(RC[2]=160,RC[-11]=24),319,IF(AND(RC[2]=160,RC[-11]=26),312,IF(AND(RC[2]=160,RC[-11]=20),301,IF(AND(RC[2]=160,RC[-11]=34),306,IF(AND(RC[2]=160,RC[-11]=36),317,IF(AND(RC[2]=160,RC[-11]=12),317,IF(AND(RC[2]=160,RC[-11]=17),320,IF(AND(RC[2]=160,RC[-11]=18),301,IF(AND(RC[2]=160,RC[-11]=33),311,IF(AND(RC[2]=160,RC[-11]=16),333,IF(AND(RC[2]=" & _
        "1]=31),317,IF(AND(RC[2]=160,RC[-11]=37),309,IF(AND(RC[2]=160,RC[-11]=11),302,IF(AND(RC[2]=160,RC[-11]=10),333,IF(AND(RC[2]=160,RC[-11]=13),319,IF(AND(RC[2]=160,RC[-11]=15),314,IF(AND(RC[2]=160,RC[-11]=25),310,(IF(AND(RC[2]=160,RC[-11]=5),313,0))))))))))))))))))))))))))))))))))))))))"
    Range("S11").Select

I'm new to Excel, so any help would be greatly appreciated.


I'm not sure where to begin on this one so I'll just point out the first thing I notice (which is significant)

Your formula is obviously broken from where you make your line breaks. I'm not sure if you accidentally deleted characters or what happened, but for instance even the first line ends with
RC[" & _
and the following line begins with
"C[-11]=

there has to have been something between those characters so when it is getting combined back together Excel cannot make any sense of it. This seems to be the case with every line break.
 
Upvote 0
I'm not sure where to begin on this one so I'll just point out the first thing I notice (which is significant)

Your formula is obviously broken from where you make your line breaks. I'm not sure if you accidentally deleted characters or what happened, but for instance even the first line ends with
RC[" & _
and the following line begins with
"C[-11]=

there has to have been something between those characters so when it is getting combined back together Excel cannot make any sense of it. This seems to be the case with every line break.

I wonder why it would do that, when recording the macro. I could understand the problem if I were writing it by hand, but when recording, you'd expect it to work as described....

Perhaps I've hit a bug in Excel?

Anyway, I'm going to go through and see if I can find where the information was deleted and patch it together.
 
Upvote 0

Forum statistics

Threads
1,215,756
Messages
6,126,691
Members
449,329
Latest member
tommyarra

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