1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
Sub TestDecompterLesCellulesVide()
Dim NbAvecNbSi As Long
Dim NbAvecCountA As Long
NbAvecNbSi = NbCellulesVidesAvecNbSi(Sheets("Feuil1"), 1, 9)
NbAvecCountA = NbCellulesVidesAvecCountA(Sheets("Feuil1"), 1, 9)
MsgBox "Nombre avec Nb.Si : " & NbAvecNbSi & Chr(10) & "Nombre avec Count A : " & NbAvecCountA
End Sub
Function NbCellulesVidesAvecNbSi(ByVal FeuilleEtudiee As Worksheet, ByVal LigneDepart As Long, ByVal ColonneEtudiee As Long) As Long
Dim DerniereLigne As Long
Dim AireSelectionnee As Range
Application.Volatile
NbCellulesVidesAvecNbSi = 0
With FeuilleEtudiee
DerniereLigne = .Cells(.Rows.Count, ColonneEtudiee).End(xlUp).Row
Set AireSelectionnee = .Range(.Cells(LigneDepart, ColonneEtudiee), .Cells(DerniereLigne, ColonneEtudiee))
NbCellulesVidesAvecNbSi = WorksheetFunction.CountIf(AireSelectionnee, "")
Set AireSelectionnee = Nothing
End With
End Function
Function NbCellulesVidesAvecCountA(ByVal FeuilleEtudiee As Worksheet, ByVal LigneDepart As Long, ByVal ColonneEtudiee As Long) As Long
Dim DerniereLigne As Long
Dim AireSelectionnee As Range
Application.Volatile
NbCellulesVidesAvecCountA = 0
With FeuilleEtudiee
DerniereLigne = .Cells(.Rows.Count, ColonneEtudiee).End(xlUp).Row
Set AireSelectionnee = .Range(.Cells(LigneDepart, ColonneEtudiee), .Cells(DerniereLigne, ColonneEtudiee))
NbCellulesVidesAvecCountA = AireSelectionnee.Cells.Count - WorksheetFunction.CountA(AireSelectionnee)
Set AireSelectionnee = Nothing
End With
End Function |
Partager