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
|
Sub ConnaitreMontant()
Dim NumeroFiscal As String
Dim LigneEnCours As Long
Dim LigneTrouvee As Boolean
Dim AireMontants As Range
With Sheets("Feuil1")
.Activate
Set AireMontants = .Range("Montant").Columns(1).Cells
NumeroFiscal = InputBox("Entrez un numéro de ligne fiscale ex : AB, I8, 0R")
If NumeroFiscal = "" Then
MsgBox "Entrez un numéro de ligne fiscal ex : AB, I8, 0R !", vbCritical
Exit Sub
End If
LigneTrouvee = False
For LigneEnCours = 1 To AireMontants.Count
If CStr(AireMontants(LigneEnCours)) = NumeroFiscal Then
MsgBox "Le montant de la ligne " & NumeroFiscal & " est de " & Format(AireMontants(LigneEnCours).Offset(0, 1), "# ##0" & "")
LigneTrouvee = True
Exit For
End If
Next LigneEnCours
If LigneTrouvee = False Then
MsgBox "Le numéro fiscal n'appartient pas au tableau !", vbCritical
End If
End With
End Sub |
Partager