+ Reply to Thread
Results 1 to 6 of 6

Formula too long? Run-time error '1004'

  1. #1
    Registered User
    Join Date
    06-12-2017
    Location
    Italy
    MS-Off Ver
    2007
    Posts
    5

    Formula too long? Run-time error '1004'

    Hello,
    I am quit new in this site and in VBA.
    I wrote a formula that works well in excel but when I register a macro system gets a Debug (Run-time error '1004')

    Formula is as follow:

    =SUMIFS(List!$G:$G;List!$BH:$BH;"No";List!$AK:$AK;"<>Yes";List!$AO:$AO;"<>Yes";List!$AL:$AL;"<>Yes";List!$AM:$AM;"<>Yes";List!$AN:$AN;"<>Yes";List!$J:$J;"X")-SUMIFS(List!$AI:$AI;List!$BH:$BH;"No";List!$AK:$AK;"<>Yes";List!$AO:$AO;"<>Yes";List!$AL:$AL;"<>Yes";List!$AM:$AM;"<>Yes";List!$AN:$AN;"<>Yes";List!$AA:$AA;"Yes";List!$AB:$AB;"<>Yes";List!$J:$J;"X")-SUMIFS(List!$AJ:$AJ;List!$BH:$BH;"No";List!$AK:$AK;"<>Yes";List!$AO:$AO;"<>Yes";List!$AL:$AL;"<>Yes";List!$AM:$AM;"<>Yes";List!$AN:$AN;"<>Yes";List!$AB:$AB;"Yes";List!$J:$J;"X")

    I have other similar formulas after that works perfectly when I type, but not when I register.
    Can you help me please?

    Thank you in advance
    Michela

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Formula too long? Run-time error '1004'

    Hi Michela,

    The macro recorder is not good with long formulas. Your code should look like this
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Registered User
    Join Date
    06-12-2017
    Location
    Italy
    MS-Off Ver
    2007
    Posts
    5

    Re: Formula too long? Run-time error '1004'

    Quote Originally Posted by xlnitwit View Post
    Hi Michela,

    The macro recorder is not good with long formulas. Your code should look like this
    Please Login or Register  to view this content.
    Hi,
    Formula definitely works very well in this way.
    I tried to apply the same rules for the other formulas but something is miss...
    You copied excel formula in VBA replacing ";" with ",", using double "" instead of " but did you do something more?

    I tried this but no way...

    ActiveCell.FormulaR1C1 = _
    "=SUMIFS(List!$G:$G,List!$BH:$BH,""No"",List!$AK:$AK,""<>Yes"",List!$AO:$AO,""<>Yes"",List!$AL:$AL,""<>Yes"",List!$AM:$AM,""<>Yes"",List!$AN:$AN,""<>Yes"",List!$J:$J,""<>X"",List!$BQ:$BQ,$A22)-SUMIFS(List!$AI:$AI,List!$BH:$BH,""No"",List!$AK:$AK,""<>Yes"",List!$AO:$AO,""<>Yes"",List!$AL:$AL,""<>Yes"",List!$AM:$AM,""<>Yes"",List!$AN:$AN,""<>Yes"",List!$AA:$AA,""Yes"",List!$AB:$AB,""<>Yes"",List!$J:$J,""<>X"",List!$BQ:$BQ,$A22)-SUMIFS(List!$AJ:$AJ,List!$BH:$BH,""No"",List!$AK:$AK,""<>Yes"",List!$AO:$AO,""<>Yes"",List!$AL:$AL,""<>Yes"",List!$AM:$AM,""<>Yes"",List!$AN:$AN,""<>Yes"",List!$AB:$AB,""Yes"",List!$J:$J,""<>X"",List!$BQ:$BQ,$A22)"

    Name error is the same
    Could you please explain me the logic inside?

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Formula too long? Run-time error '1004'

    You should be using the Formula property and not FormulaR1C1

  5. #5
    Registered User
    Join Date
    06-12-2017
    Location
    Italy
    MS-Off Ver
    2007
    Posts
    5

    Re: Formula too long? Run-time error '1004'

    Super !
    Thank you soo much :-)
    Have a nice day

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Formula too long? Run-time error '1004'

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Error 1004 when pasting a long formula in Macro
    By pauldst in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-14-2017, 04:15 PM
  2. Long Formula Getting 1004 error when running VBA
    By johnmahon12 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-25-2016, 08:08 AM
  3. Replies: 1
    Last Post: 03-12-2014, 12:42 PM
  4. long formula to vba macro - error 1004 unable to set formulaarray property
    By desibabuji in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-08-2013, 06:18 AM
  5. Replies: 1
    Last Post: 09-23-2011, 10:35 AM
  6. runtime 1004 error - string to long
    By SarahPintal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-14-2009, 02:55 AM
  7. Code too long? Error 1004
    By mole2704 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-03-2008, 07:25 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1