Scinder un code VBA trop long (méthode)

Bonjour à tous.

Je ne parviens pas à faire rentrer une formule VBA qui est trop longue.

J'essaie donc de la couper en 2 avec l'astuce du "_" mais rien à faire. Ça ne fonctionne pas et je n'arrive pas non plus à trouver une méthode précise pour savoir après quelle fonction je peux ou pas découper ma ligne.

Merci par avance si quelqu'un peut m'aider.

Voici le code :

'
    ActiveCell.FormulaR1C1 = _
        "=IF(OR(RC[-7]=""EgaCost"",RC[-7]=""GoCost""),""0"",IF(RC[-14]="""","""",IF(OR(MID(RC[-10],1,11)=IFERROR(VLOOKUP(MID(RC[-10],1,11),R3C21:R501C21,1,FALSE),""¤""),MID(RC[-11],1,11)=IFERROR(VLOOKUP(MID(RC[-11],1,11),R3C21:R501C21,1,FALSE),""¤""),MID(RC[-10],1,6)=IFERROR(VLOOKUP(MID(RC[-10],1,6),R3C18:R501C18,1,FALSE),""¤""),MID(RC[-10],1,4)=IFERROR(VLOOKUP(MID(RC[-10],1,4),R3C19:R501C19,1,FALSE),""¤""),MID(RC[-10],1,3)=IFERROR(VLOOKUP(MID(RC[-10],1,3),R3C20:R501C20,1,FALSE),""¤""),MID(RC[-11],1,6)=IFERROR(VLOOKUP(MID(RC[-11],1,6),R3C18:R501C18,1,FALSE),""¤""),MID(RC[-11],1,4)=IFERROR(VLOOKUP(MID(RC[-11],1,4),R3C19:R501C19,1,FALSE),""¤""),MID(RC[-11],1,3)=IFERROR(VLOOKUP(MID(RC[-11],1,3),R3C20:R501C20,1,FALSE),""¤""),MID(RC[-14],1,6)=IFERROR(VLOOKUP(MID(RC[-14],1,6),R3C17:R501C17,1,FALSE),""¤""),RC[-14]=IFERROR(VLOOKUP(RC[-14],R3C17:R501C17,1,FALSE),""¤""),RC[-1]=""VRAI""),""3"",IFERROR(IF(AND(RC[-11]="""",RC[-10]=""""),"""",IF(AND(RC[-1]=""FAUX"",RC[-4]="""",MID(RC[-4],1,8)<>IFERROR(VLOOKUP(MID(RC
[-4],1,8),R3C17:R501C17,1,FALSE),""¤"")),""NIMI"",""0"")),""""))))"
        Select

bonjour,

une manière de faire

   ActiveCell.FormulaR1C1 = _
        "=IF(OR(RC[-7]=""EgaCost"",RC[-7]=""GoCost""),""0"",IF(RC[-14]="""",""""," & _
        "IF(OR(MID(RC[-10],1,11)=IFERROR(VLOOKUP(MID(RC[-10],1,11),R3C21:R501C21,1,FALSE),""¤"")," & _
        "MID(RC[-11],1,11)=IFERROR(VLOOKUP(MID(RC[-11],1,11),R3C21:R501C21,1,FALSE),""¤"")," & _
        "MID(RC[-10],1,6)=IFERROR(VLOOKUP(MID(RC[-10],1,6),R3C18:R501C18,1,FALSE),""¤"")," & _
        "MID(RC[-10],1,4)=IFERROR(VLOOKUP(MID(RC[-10],1,4),R3C19:R501C19,1,FALSE),""¤"")," & _
        "MID(RC[-10],1,3)=IFERROR(VLOOKUP(MID(RC[-10],1,3),R3C20:R501C20,1,FALSE),""¤"")," & _
        "MID(RC[-11],1,6)=IFERROR(VLOOKUP(MID(RC[-11],1,6),R3C18:R501C18,1,FALSE),""¤"")," & _
        "MID(RC[-11],1,4)=IFERROR(VLOOKUP(MID(RC[-11],1,4),R3C19:R501C19,1,FALSE),""¤"")," & _
        "MID(RC[-11],1,3)=IFERROR(VLOOKUP(MID(RC[-11],1,3),R3C20:R501C20,1,FALSE),""¤"")," & _
        "MID(RC[-14],1,6)=IFERROR(VLOOKUP(MID(RC[-14],1,6),R3C17:R501C17,1,FALSE),""¤"")," & _
        "RC[-14]=IFERROR(VLOOKUP(RC[-14],R3C17:R501C17,1,FALSE),""¤""),RC[-1]=""VRAI""),""3""," & _
        "IFERROR(IF(AND(RC[-11]="""",RC[-10]=""""),"""",IF(AND(RC[-1]=""FAUX"",RC[-4]=""""," & _
        "MID(RC[-4],1,8)<>IFERROR(VLOOKUP(MID(RC[-4],1,8),R3C17:R501C17,1,FALSE),""¤"")),""NIMI"",""0"")),""""))))

Bonjour

par Dubois, VbaNEw merci à eux :

une idée ici https://forum.excel-pratique.com/excel/vba-separer-en-2-une-longue-formule-t16410.html

crdlt,

André

J'ai droit au code + la méthode, merci beaucoup vous êtes super !!

je test ça dans l'après midi et je vais certainement rajouter la technique dans mon classeur..

Encore merci !

Ça marche super bien, sujet clos encore merci

Rechercher des sujets similaires à "scinder code vba trop long methode"