Erreur'5': Argument ou appel de procédure incorrect

Bonjour à tous,

pouvez vous m'aider svp.

Je suis nouveau sur le forme voici mon soucis j'ai ecrit un code de calcul qui me permet d'automatiser une procédure en VBA ( novice ) et lorsque je lance mon code qui s'exécute bien j'ai un message du type Erreur'5': Argument ou appel de procédure incorrect et je n'arrive pas à trouver d'ou cela peut bien venir ???

Merci d'avance pour votre aide ci joint le code

Dim wk1 As Workbook
    Dim wk1sh1 As Worksheet
    Dim wk1sh2 As Worksheet

    Dim LSD_Source As Byte
    Dim HRD_Source As Byte
    Dim Facteur_tiges As Double
    Dim a0_LSD As Double
    Dim a1_LSD As Double
    Dim a0_HRD As Double
    Dim a1_HRD As Double

'affectation
    Set wk1 = ActiveWorkbook
    Set wk1sh1 = wk1.Worksheets("Data")
    Set wk1sh2 = wk1.Worksheets("Processing")

Calcul.Show 0
Calcul.Repaint

'calibration
LSD_Source = wk1sh2.Cells(4, 22)
HRD_Source = wk1sh2.Cells(4, 21)
Facteur_tiges = wk1sh2.Cells(6, 22)
a0_LSD = wk1sh2.Cells(9, 21)
a1_LSD = wk1sh2.Cells(9, 22)
a0_HRD = wk1sh2.Cells(12, 21)
a1_HRD = wk1sh2.Cells(12, 22)

'data importation
n_LIG = 3
Do While wk1sh1.Cells(n_LIG, 1) <> ""
wk1sh2.Cells(n_LIG, 1) = wk1sh1.Cells(n_LIG, 1)
wk1sh2.Cells(n_LIG, 1).Interior.ColorIndex = 6
wk1sh2.Cells(n_LIG, 18) = wk1sh1.Cells(n_LIG, 1)
wk1sh2.Cells(n_LIG, 18).Interior.ColorIndex = 40
wk1sh2.Cells(n_LIG, 2) = wk1sh1.Cells(n_LIG, 2)
wk1sh2.Cells(n_LIG, 2).Interior.ColorIndex = 6
wk1sh2.Cells(n_LIG, 3) = wk1sh1.Cells(n_LIG, 3)
wk1sh2.Cells(n_LIG, 3).Interior.ColorIndex = 6
n_LIG = n_LIG + 1
Loop

'calcul de la densité en tubage
n_LIG = 3
Do
wk1sh2.Cells(n_LIG, 4) = 1 / (Facteur_tiges) * wk1sh2.Cells(n_LIG, 2)
wk1sh2.Cells(n_LIG, 5) = 1 / (Facteur_tiges) * wk1sh2.Cells(n_LIG, 3)
wk1sh2.Cells(n_LIG, 6) = Exp((Log(wk1sh2.Cells(n_LIG, 4)) / (LSD_Source) - (Log(wk1sh2.Cells(n_LIG, 5)) / (HRD_Source))) / ((1 / (LSD_Source) - 1 / (HRD_Source))))

wk1sh2.Cells(n_LIG, 7) = Log((wk1sh2.Cells(n_LIG, 6) / wk1sh2.Cells(n_LIG, 4))) * 1 / (LSD_Source)
wk1sh2.Cells(n_LIG, 8) = Log((wk1sh2.Cells(n_LIG, 6) / wk1sh2.Cells(n_LIG, 5))) * 1 / (HRD_Source)
wk1sh2.Cells(n_LIG, 9) = wk1sh2.Cells(n_LIG, 6) / Facteur_tiges
wk1sh2.Cells(n_LIG, 10) = wk1sh2.Cells(n_LIG, 9) * Exp(-wk1sh2.Cells(n_LIG, 7) * LSD_Source)
wk1sh2.Cells(n_LIG, 11) = wk1sh2.Cells(n_LIG, 9) * Exp(-wk1sh2.Cells(n_LIG, 8) * HRD_Source)
wk1sh2.Cells(n_LIG, 12) = a1_LSD * Log(wk1sh2.Cells(n_LIG, 10)) + a0_LSD
wk1sh2.Cells(n_LIG, 13) = a1_HRD * Log(wk1sh2.Cells(n_LIG, 11)) + a0_HRD

'resultats
wk1sh2.Cells(n_LIG, 14) = 1.0704 * wk1sh2.Cells(n_LIG, 12) - 0.1883
wk1sh2.Cells(n_LIG, 15) = 1.0704 * wk1sh2.Cells(n_LIG, 13) - 0.1883
wk1sh2.Cells(n_LIG, 17) = 1.0704 * (4 / 3 * wk1sh2.Cells(n_LIG, 12) - 1 / 3 * wk1sh2.Cells(n_LIG, 13)) - 0.1883
wk1sh2.Cells(n_LIG, 14).Interior.ColorIndex = 20
wk1sh2.Cells(n_LIG, 15).Interior.ColorIndex = 20
wk1sh2.Cells(n_LIG, 17).Interior.ColorIndex = 40
n_LIG = n_LIG + 1
Loop
Unload Calcul

End Sub

Bonjour,

Si ton code s'exécutait bien, il n'y aurait pas d'erreur 5 !

Tu n'as pas indiqué sur quelle ligne ?

Ton pavé (non indenté) étant plutôt indigeste à lire, il serait bon d'au moins fournir cette information.

dsl Ferrand je débute sur excel effectivement je doit faire des efforts et indenté mon code

par contre il ne me dit pas c'est sur quelle ligne ?

Merci

Tu es sûr ?

S'il n'y a pas de ligne surlignée en jaune dans le code, et que c'est la ligne Sub... qui est surlignée en jaune, il devrait y avoir quelque part un mot ou une expression surlignée (discrètement) en bleu.

Rechercher des sujets similaires à "erreur argument appel procedure incorrect"