Bonjour,

J'essaie d'insérer une formule à partir d'une macro, mais je n'arrive pas à savoir d'où provient l'erreur.
j'ai une erreur 13 type mismatch mais je ne crois pas que l'erreur provienne de mes variables :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
    Dim aa As String
    aa = Left(Ccable, 6)
    Dim bb As Variant
    Dim bb2 As Variant
    bb = Cells(LigneUti + 1, ColUti - 2).Address
    bb2 = Cells(LigneUti - 2, ColUti - 2).Address
    Dim cc As Variant
    Dim cc2 As Variant
    cc = Cells(Ligne1 + 1, Col1 + 9).Address
    cc2 = Cells(Ligne1 - 2, Col1 + 9).Address
    Dim CodeG2r As String
    CodeG2r = Cells(10, 8).Address
 
MaPlage.Value = _
    "= IF(COUNTIF(" & bb2 & ",""*PB*""),"" SFR "" & " & CodeG2r & " & " & aa & " & "" - A ""& I24 & ""-"" & SUBSTITUTE(" & bb2 & ",""O"","""") &"" O ""& IF(COUNTIF(" & cc2 & ",""*PB*""),I24 & ""-"" &SUBSTITUTE(" & cc2 & ",""O"","""") & "" E"",IF(COUNTIF(" & cc & ",""*mM*"")+COUNTIF(" & cc & ",""*BPE*"")+COUNTIF(" & cc & ",""*M*""),RIGHT(" & cc & ",LEN(" & cc & ")-SEARCH(" - "" & _
         "" & cc & ",1))," & cc & ")&IF(COUNTIF(" & cc & ",""*FT*""),"""",""-FT"") & "" E""), "" SFR "" & " & CodeG2r & " &" & aa & " & "" - A "" & IF(COUNTIF(" & bb & ",""*mM*"")+COUNTIF(" & bb & ",""*BPE*"")+COUNTIF(" & bb & ",""*M*""),RIGHT(" & bb & ",LEN(R[-8]C[-8])-SEARCH(""-""," & bb & ",1))," & bb & ")&IF(COUNTIF(" & bb & ",""*FT*""),"""",""-FT"") & "" O "" & IF(COUNTIF(" & bb2 & "" & _
        "*PB*""),I24 & ""-"" & SUBSTITUTE(" & cc2 & ",""O"","""") & "" E"",IF(COUNTIF(" & cc & ",""*mM*"")+COUNTIF(" & cc & ",""*BPE*"")+COUNTIF(" & cc & ",""*M*""),RIGHT(" & cc & ",LEN(" & cc & ")-SEARCH(""-""," & cc & ",1))," & cc & ")&IF(COUNTIF(" & cc & ",""*FT*""),"""",""-FT"") & "" E"" ))"
Désolé pour cette formule indigeste, c'est justement pour ca que je n'arrive pas à savoir où est le pb... Un pro de la formule serait il dans le coin?