Boucle : saut de ligne

Bonjour à tous,

Je sèche sur un problème relativement mineur, faire une boucle qui saute les lignes sans data notamment ici la 10 et la 17 et j'ai beau jouer avec les step ca ne marche pas.

J'ai donc laissé la boucle sans step de 4 à 9 car pour le moment mon bricolage fonctionne.

Pouvez vous m'indiquez ce que vous feriez ? utiliser step ou non ? Voici le code et le fichier est joint.

Sub Rectangle1_Cliquer()

Dim Plafond As Integer
Dim x As Integer

Plafond = Range("B1").Value

For x = 4 To 9

    If Range("B" & x).Value <= 0 Then
       Range("B" & x).Font.Color = RGB(155, 0, 0)
       Range("B" & x).Font.Bold = True
    Else
       Range("B" & x).Font.Color = RGB(0, 0, 0)
    End If

    If Range("B" & x).Value > Plafond Then
       Range("C" & x).Value = Range("B" & x).Value - Plafond 'ChrW(&H2192)
       Range("B" & x).Value = Range("B" & x).Value - Range("C" & x).Value
       Range("D" & x).Value = Range("D" & x).Value + Range("C" & x).Value
    Else
    End If

Next x

End Sub

Je vous remercie sincèrement.

Variable (D'humeur)

19forum-r6.xlsm (17.32 Ko)

Bonjour,

Sub Rectangle1_Cliquer()

Dim Plafond As Integer
Dim x As Integer
LastRw = Cells(Rows.Count, 1).End(xlUp).Row
Plafond = Range("B1").Value

For x = 4 To LastRw
  If Range("A" & x) <> "" Then

    If Range("B" & x).Value <= 0 Then
       Range("B" & x).Font.Color = RGB(155, 0, 0)
       Range("B" & x).Font.Bold = True
    Else
       Range("B" & x).Font.Color = RGB(0, 0, 0)
    End If

    If Range("B" & x).Value > Plafond Then
       Range("C" & x).Value = Range("B" & x).Value - Plafond 'ChrW(&H2192)
       Range("B" & x).Value = Range("B" & x).Value - Range("C" & x).Value
       Range("D" & x).Value = Range("D" & x).Value + Range("C" & x).Value
    Else
    End If
  End If
Next x
End Sub

Coucou sabV

wow, j'ai beau retourner cette instruction sous tout les angles je comprends pas comment elle fait pour indiquer à boucle de sauter les bonnes lignes ?

LastRw = Cells(Rows.Count, 1).End(xlUp).Row
........
for x = 4 to LastRw
...................................

celle-ci le fait

If Range("A" & x) <> "" Then 'sous entendu  If not then go to next

D'accord, si je comprends bien tant que a est rempli continuer la boucle jusqu'à la dernière ligne possédant du contenu c'est exact ?

D'accord, si je comprends bien tant que a est rempli continuer la boucle jusqu'à la dernière ligne possédant du contenu c'est exact ?

c'est en plein ça

monsieur sabV, ton aide encore une fois m'a été précieuse MERCI ! Je clôture par un ✔

Rechercher des sujets similaires à "boucle saut ligne"