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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
Public Function FctCompteLignes( _
ByRef IntNbLignes As Integer, _
Optional ByVal StrActif As String, _
Optional ByVal StrAdresseDepart As String = "A1") As Boolean
'
Dim RangeDonnee As Range
Dim RangeDown As Range
Dim StrAdresse As String
Dim StrAdresseSub As String
Dim LngDerniereLigne As Long
'
Dim BoolResult As Boolean
Dim StrNomProcApp As String 'Stockage de la procédure appelante
On Error GoTo Erreur
'Gestion des erreurs
'**************************
StrNomProcApp = NomProc
NomProc = "FctCompteLignes" 'Gestion des erreurs (procédure en cours)
BoolResult = False
'Traitement
'**************************
If Not FctSelectionRangeColonne(StrAdresse, StrActif, StrAdresseDepart) Then
GoTo Sortie
End If
StrAdresseSub = (Split(StrAdresse, ":")(1))
StrAdresse = (Split(StrAdresseSub, "$")(2))
IntNbLignes = CLng(StrAdresse)
BoolResult = True
Sortie:
'Libération de la mémoire
Set RangeDonnee = Nothing
Set RangeDown = Nothing
'Cloture
NomProc = StrNomProcApp
FctCompteLignes = BoolResult
Exit Function
Erreur:
MsgBox NomProc & vbCr & Err.Number & " - " & Err.Description, vbCritical
BoolResult = False
GoTo Sortie
End Function
Public Function FctSelectionRangeColonne( _
ByRef StrAdresse As String, _
Optional ByVal StrActif As String, _
Optional ByVal StrAdresseDepart As String = "A1") As Boolean
'
Dim BoolResult As Boolean
Dim StrNomProcApp As String 'Stockage de la procédure appelante
'
Dim RangeDonnee As Range
Dim RangeDown As Range
On Error Resume Next
'Gestion des erreurs
'**************************
StrNomProcApp = NomProc
NomProc = "FctSelectionRangeColonne" 'Gestion des erreurs (procédure en cours)
BoolResult = False
'Traitement
' '**************************
' Set RangeDonnee = IIf(Trim(StrActif) = "", ThisWorkbook.Worksheets(1).Range(StrAdresseDepart), ThisWorkbook.Worksheets(StrActif).Range(StrAdresseDepart))
If (Trim(StrActif) = "") Then
Set RangeDonnee = ThisWorkbook.Worksheets(1).Range(StrAdresseDepart)
Else
Set RangeDonnee = ThisWorkbook.Worksheets(StrActif).Range(StrAdresseDepart)
End If
Set RangeDown = Range(RangeDonnee.Cells, RangeDonnee.End(xlDown).Cells)
StrAdresse = RangeDown.Address
BoolResult = True
Sortie:
'Libération de la mémoire
Set RangeDonnee = Nothing
Set RangeDown = Nothing
'Cloture
NomProc = StrNomProcApp
FctSelectionRangeColonne = BoolResult
Exit Function
Erreur:
MsgBox NomProc & vbCr & Err.Number & " - " & Err.Description, vbCritical
BoolResult = False
GoTo Sortie
End Function |
Partager