Problème de boucle avec for
Résolu
davsnoop
-
ShaBoo Messages postés 392 Date d'inscription Statut Membre Dernière intervention -
ShaBoo Messages postés 392 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
Je n'arrive pas a faire une macro exel qui me conte le nombre de cellule non vide dans une colone.
Je fait la boucle suivante mais ca ne marche pas
Dim i As Integer
Dim var As Variant
i = 1
var = 1
For i = 1 To var
If Cells(i, 1) <> "" Then
var = i + 1
Else
Exit For
End If
Next i
Je n'arrive pas a faire une macro exel qui me conte le nombre de cellule non vide dans une colone.
Je fait la boucle suivante mais ca ne marche pas
Dim i As Integer
Dim var As Variant
i = 1
var = 1
For i = 1 To var
If Cells(i, 1) <> "" Then
var = i + 1
Else
Exit For
End If
Next i
A voir également:
- Problème de boucle avec for
- Downloader for pc - Télécharger - Téléchargement & Transfert
- Idm for mac - Télécharger - Téléchargement & Transfert
- Copytrans heic for windows - Télécharger - Visionnage & Diaporama
- Instagram for pc - Télécharger - Divers Communication
- Microsoft store download for pc - Guide
2 réponses
Bonjour,
tu peux essayer ceci :
tu peux essayer ceci :
Dim iLineRead As Integer Dim iNbLine As Integer Dim iNbCellNoEmpty As Integer iLineRead = 1 iNbLine = Sheets(1).Range("A65536").End(xlUp).Row iNbCellNoEmpty = 0 Do Until iLineRead = iNbLine If Trim(Sheets(1).Cells(iLineRead, 1)) <> "" Then iNbCellNoEmpty = iNbCellNoEmpty + 1 End If iLineRead = iLineRead + 1 Loop MsgBox "Nombre de cellule non vide = " & iNbCellNoEmpty
Avec un For cela donnera ceci :
Dim iLineRead As Integer Dim iNbLine As Integer Dim iNbCellNoEmpty As Integer iLineRead = 1 iNbLine = Sheets(1).Range("A65536").End(xlUp).Row iNbCellNoEmpty = 0 For iLineRead = 1 To iNbLine If Trim(Sheets(1).Cells(iLineRead, 1)) <> "" Then iNbCellNoEmpty = iNbCellNoEmpty + 1 End If Next iLineRead MsgBox "Nombre de cellule non vide = " & iNbCellNoEmpty