Fonction If en boucle continue

Bonjour,

Je souhaite réaliser une fonction if en boucle continue jusqu'a son arrêt mais je n'ai pas réussis.

     If Lifetime < Lifetime * Application.WorksheetFunction.RoundUp(remplacement, 0) Then
     Range("B14") = Lifetime - Lifetime
End If
     If Lifetime * 2 < Lifetime * Application.WorksheetFunction.RoundUp(remplacement, 0) Then
     Range("C14") = Lifetime
End If
     If 3 * Lifetime < Lifetime * Application.WorksheetFunction.RoundUp(remplacement, 0) Then
     Range("D14") = 3 * Lifetime - Lifetime
End If
     If 4 * Lifetime < Lifetime * Application.WorksheetFunction.RoundUp(remplacement, 0) Then
     Range("E14") = 4 * Lifetime - Lifetime
End If
     If 5 * Lifetime < Lifetime * Application.WorksheetFunction.RoundUp(remplacement, 0) Then
     Range("F14") = 5 * Lifetime - Lifetime
End If
     If 6 * Lifetime < Lifetime * Application.WorksheetFunction.RoundUp(remplacement, 0) Then
     Range("G14") = 6 * Lifetime - Lifetime
End If
     If 7 * Lifetime < Lifetime * Application.WorksheetFunction.RoundUp(remplacement, 0) Then
     Range("H14") = 7 * Lifetime - Lifetime
End If
     If 8 * Lifetime < Lifetime * Application.WorksheetFunction.RoundUp(remplacement, 0) Then
     Range("I14") = 8 * Lifetime - Lifetime
End If
     If 9 * Lifetime < Lifetime * Application.WorksheetFunction.RoundUp(remplacement, 0) Then
     Range("J14") = 9 * Lifetime - Lifetime
End If
     If 10 * Lifetime < Lifetime * Application.WorksheetFunction.RoundUp(remplacement, 0) Then
     Range("K14") = 10 * Lifetime - Lifetime
End If
     If 10 * Lifetime < Lifetime * Application.WorksheetFunction.RoundUp(remplacement, 0) Then
     Range("L14") = 10 * Lifetime - Lifetime
End If

Voici le seul moyen que j'ai touvé mais évidemment je sais qu'il est possible d'automatiser tout ça.

De plus j'aimerais avoir le résultat dans une case séparé par des virgules mais je ne sais pas comment faire.

Auriez-vous une solution à ce problème?

Bonjour,

Bonjour Adri, bonjour Bruno;

Cela pourrait ressembler à quelque chose comme cela :

Sub boucl()

If Lifetime < Lifetime * Application.WorksheetFunction.RoundUp(remplacement, 0) Then
     Range("B14") = Lifetime - Lifetime
End If
If Lifetime * 2 < Lifetime * Application.WorksheetFunction.RoundUp(remplacement, 0) Then
     Range("C14") = Lifetime
End If
Lettre = 4 'colonne D
For Ind = 3 To 11
     If Lifetime * Ind < Lifetime * Application.WorksheetFunction.RoundUp(remplacement, 0) Then
        Cells(14, Lettre) = Ind * Lifetime - Lifetime

    End If
    Lettre = Lettre + 1
Next Ind

End Sub

Mais cela n'est pas bien clair pour nous, donc comme dit Bruno, un extrait de fichier serait le bienvenu.

Bonne soirée à tous

Ci-joint mon dossier, le code ne marche pas.

2vba-project.pdf (64.61 Ko)

Bonjour

@Patty5046, ce n'est pas pour rien que nous demandons les fichiers

@Adri1998en, pensez à utiliser l'outil de confidentialité prévu dans Excel quand vous postez un fichier
Sinon

image

A+

j'ai essayé de faire un test mais ça ne m'affiche rien.

Sub boucl()
Dim fois As Integer

fois = 1
lettre = 4

Do While fois * Lifetime < Lifetime * Application.WorksheetFunction.RoundUp(remplacement, 0)

Cells(lettre, 20) = fois * Lifetime - Lifetime
fois = fois + 1
lettre = lettre + 1
Loop

End Sub

Ah je connaissais pas, je vais l'utiliser maintenant.

Re,

Avec ça

 Dim Col As Long, RempltInt As Integer
 For Col = 1 To Remplacement
    Cells(14, 1 + Col) = (Col * Lifetime) - Lifetime
 Next Col

En définissant "Remplacement" comme suit

Dim Remplacement as Integer

A+

Rechercher des sujets similaires à "fonction boucle continue"