debidebo67
XLDnaute Nouveau
Bonjour,
l'écriture du code VBA est accepté mais les résultats ne sont pas les bons, pourtant j'ai beau relire ça me parait juste. c'est comme s'il ne prend pas en compte certains ElseIf !?!
comme ça ne marche pas je pense que la manière de l'écrire n'est pas la bonne !
pourriez-vous m'aider SVP ?
Sub essaimacroboucle()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim i As Integer
Worksheets("tableau 1").Range("P51000").ClearContents
For i = 5 To 1000
'tous remli
If Cells(i, 6) & Cells(i, 7) & Cells(i, 8) & Cells(i, 9) = "" Then
Cells(i, 16).Value = ""
'manque 1
ElseIf (Cells(i, 8) = "") And Not (Cells(i, 6) & Cells(i, 7) & Cells(i, 9) = "") Then
Cells(i, 16).Value = Cells(i, 6) & " - " & Cells(i, 7) & " - " & Cells(i, 9)
ElseIf (Cells(i, 7) = "") And Not (Cells(i, 6) & Cells(i, 8) & Cells(i, 9) = "") Then
Cells(i, 16).Value = Cells(i, 6) & " - " & Cells(i, 8) & " - " & Cells(i, 9)
ElseIf (Cells(i, 9) = "") And Not (Cells(i, 6) & Cells(i, 7) & Cells(i, 8) = "") Then
Cells(i, 16).Value = Cells(i, 6) & " - " & Cells(i, 7) & " - " & Cells(i, 8)
'manque 2
ElseIf (Cells(i, 8) = "") And (Cells(i, 9) = "") And Not (Cells(i, 6) & Cells(i, 7) = "") Then
Cells(i, 16).Value = Cells(i, 6) & " - " & Cells(i, 7)
ElseIf (Cells(i, 7) = "") And (Cells(i, 8) = "") And Not (Cells(i, 6) & Cells(i, 9) = "") Then
Cells(i, 16).Value = Cells(i, 6) & " - " & Cells(i, 9)
'manque 3
ElseIf (Cells(i, 7) & Cells(i, 8) & Cells(i, 9) = "") And Not (Cells(i, 6) = "") Then
Cells(i, 16).Value = Cells(i, 6)
'sinon rien
Else
Cells(i, 16).Value = Cells(i, 6) & " - " & Cells(i, 7) & " - " & Cells(i, 8) & " - " & Cells(i, 9)
End If
Next i
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
l'écriture du code VBA est accepté mais les résultats ne sont pas les bons, pourtant j'ai beau relire ça me parait juste. c'est comme s'il ne prend pas en compte certains ElseIf !?!
comme ça ne marche pas je pense que la manière de l'écrire n'est pas la bonne !
pourriez-vous m'aider SVP ?
Sub essaimacroboucle()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim i As Integer
Worksheets("tableau 1").Range("P51000").ClearContents
For i = 5 To 1000
'tous remli
If Cells(i, 6) & Cells(i, 7) & Cells(i, 8) & Cells(i, 9) = "" Then
Cells(i, 16).Value = ""
'manque 1
ElseIf (Cells(i, 8) = "") And Not (Cells(i, 6) & Cells(i, 7) & Cells(i, 9) = "") Then
Cells(i, 16).Value = Cells(i, 6) & " - " & Cells(i, 7) & " - " & Cells(i, 9)
ElseIf (Cells(i, 7) = "") And Not (Cells(i, 6) & Cells(i, 8) & Cells(i, 9) = "") Then
Cells(i, 16).Value = Cells(i, 6) & " - " & Cells(i, 8) & " - " & Cells(i, 9)
ElseIf (Cells(i, 9) = "") And Not (Cells(i, 6) & Cells(i, 7) & Cells(i, 8) = "") Then
Cells(i, 16).Value = Cells(i, 6) & " - " & Cells(i, 7) & " - " & Cells(i, 8)
'manque 2
ElseIf (Cells(i, 8) = "") And (Cells(i, 9) = "") And Not (Cells(i, 6) & Cells(i, 7) = "") Then
Cells(i, 16).Value = Cells(i, 6) & " - " & Cells(i, 7)
ElseIf (Cells(i, 7) = "") And (Cells(i, 8) = "") And Not (Cells(i, 6) & Cells(i, 9) = "") Then
Cells(i, 16).Value = Cells(i, 6) & " - " & Cells(i, 9)
'manque 3
ElseIf (Cells(i, 7) & Cells(i, 8) & Cells(i, 9) = "") And Not (Cells(i, 6) = "") Then
Cells(i, 16).Value = Cells(i, 6)
'sinon rien
Else
Cells(i, 16).Value = Cells(i, 6) & " - " & Cells(i, 7) & " - " & Cells(i, 8) & " - " & Cells(i, 9)
End If
Next i
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub