Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

Arrêter boucle si cellule vide

Enzel

XLDnaute Nouveau
Bonjour!

On ma donner un morceau de code et j'essaye de le modifier pour que la boucle s'arrête lorsqu'il y a une cellule vide. En fait je voudrais que lors de la initialisation à ".TypeText Text:=Range("C" & i + 19).Text" il y est une vérification si la cellule est vide ou non, si vide arrêter la boucle. Merci !!

VB:
    With WordObj.Selection ' assignation des signets
   
        For i = 1 To 156 and
       
                .GoTo What:=wdGoToBookmark, Name:="tube" & i ' recherche du signet
                .TypeText Text:=Range("C" & i + 19).Text
       
            If Feuil2.CheckBox4.Value = True Then

                .GoTo What:=wdGoToBookmark, Name:="dim" & i 'Signet N° commande client
                .TypeText Text:=Range("D11").Text

            End If

            If Feuil2.CheckBox2.Value = True Then

                .GoTo What:=wdGoToBookmark, Name:="coulee" & i 'Signets coulée
                .TypeText Text:=Range("D9").Text

            End If

            If Feuil2.CheckBox1.Value = True Then

                .GoTo What:=wdGoToBookmark, Name:="lot" & i 'Signets lots
                .TypeText Text:=Range("D8").Text

            End If
           
            If Feuil2.CheckBox5.Value = True Then

                .GoTo What:=wdGoToBookmark, Name:="norme" & i 'Signets item
                .TypeText Text:=Range("D12").Text

            End If
                     
            If Feuil2.CheckBox3.Value = True Then

                .GoTo What:=wdGoToBookmark, Name:="item" & i 'Signets nuance
                .TypeText Text:=Range("D10").Text

            End If
              
            If Feuil2.CheckBox10.Value = True Then

                .GoTo What:=wdGoToBookmark, Name:="plan" & i 'Signets norme
                .TypeText Text:=Range("D13").Text

            End If
                       
            If Feuil2.CheckBox8.Value = True Then

                .GoTo What:=wdGoToBookmark, Name:="cde" & i 'Signets dimensions
                .TypeText Text:=Range("I8").Text

            End If
           
        Next i
   
    End With
 

Discussions similaires

Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…