Bonjour à tous
J’ai deux macros qui me permettre de passer de mois en mois dans mon tableau
Une en descendant
Et une en montant
De même j’ai deux macros qui me permettre de passer d’année en année
Une en descendant
Et une en montant
Les 2 macros qui vont en descendant fonctionnent parfaitement
Les 2 macros en montant bloquent
Erreur d'execution '13' : Incompatibilité de type
Pour celle des années sur :
If Year(Range("B" & n)) = suiv Then
Pour celle des mois sur :
If Month(Range("B" & n)) = suiv Then
Ne pouvant mettre le fichier
Je joins les 4 macros
Si quelqu’un peut m’aider, je le remercie d’avance
Les 4 macros :
Sub Vers_premier_jour_mois_suivant()
' Passage de mois en mois en descendant
' Touche de raccourci du clavier: Ctrl+S
Cells(ActiveCell.Row, 2).Select
If Selection.Column <> 2 Then Exit Sub
x = Month(Selection.Value)
suiv = x + 1
If suiv = 13 Then suiv = 1
For n = Selection.Row To Range("B" & Rows.Count).End(xlUp).Row
If Month(Range("B" & n)) = suiv Then
Range("B" & n).Select
Exit For
End If
Next
ActiveWindow.ScrollRow = Selection.Row
End Sub
----------------
Sub Vers_premier_jour_mois_precedent()
' Passage de mois en mois en remontant
' Touche de raccourci du clavier: Ctrl+P
Cells(ActiveCell.Row, 2).Select
If Selection.Column <> 2 Then Exit Sub
x = Month(Selection.Value)
suiv = x - 1
If suiv = 0 Then suiv = 13
For n = 4 To Range("B" & Rows.Count).End(xlUp).Row
If Month(Range("B" & n)) = suiv Then
Range("B" & n).Select
Exit For
End If
Next
ActiveWindow.ScrollRow = Selection.Row
End Sub
--------------------
Sub Vers_premier_jour_annee_suivante()
' Passage d'année en année en descendant
Cells(ActiveCell.Row, 2).Select
If Selection.Column <> 2 Then Exit Sub
x = Year(Selection.Value)
suiv = x + 1
'If suiv = 13 Then suiv = 1
For n = Selection.Row To Range("B" & Rows.Count).End(xlUp).Row
If Year(Range("B" & n)) = suiv Then
Range("B" & n).Select
Exit For
End If
Next
ActiveWindow.ScrollRow = Selection.Row
End Sub
----------------------
Sub Vers_premier_jour_annee_precedente()
' Passage d'année en année en remontant
' Touche de raccourci du clavier: Ctrl+P
Cells(ActiveCell.Row, 2).Select
If Selection.Column <> 2 Then Exit Sub
x = Year(Selection.Value)
Cells(ActiveCell.Row, 2).Select
suiv = x - 1
If suiv = 0 Then suiv = 13
For n = 4 To Range("B" & Rows.Count).End(xlUp).Row
If Year(Range("B" & n)) = suiv Then
Range("B" & n).Select
Exit For
End If
Next
ActiveWindow.ScrollRow = Selection.Row
End Sub
J’ai deux macros qui me permettre de passer de mois en mois dans mon tableau
Une en descendant
Et une en montant
De même j’ai deux macros qui me permettre de passer d’année en année
Une en descendant
Et une en montant
Les 2 macros qui vont en descendant fonctionnent parfaitement
Les 2 macros en montant bloquent
Erreur d'execution '13' : Incompatibilité de type
Pour celle des années sur :
If Year(Range("B" & n)) = suiv Then
Pour celle des mois sur :
If Month(Range("B" & n)) = suiv Then
Ne pouvant mettre le fichier
Je joins les 4 macros
Si quelqu’un peut m’aider, je le remercie d’avance
Les 4 macros :
Sub Vers_premier_jour_mois_suivant()
' Passage de mois en mois en descendant
' Touche de raccourci du clavier: Ctrl+S
Cells(ActiveCell.Row, 2).Select
If Selection.Column <> 2 Then Exit Sub
x = Month(Selection.Value)
suiv = x + 1
If suiv = 13 Then suiv = 1
For n = Selection.Row To Range("B" & Rows.Count).End(xlUp).Row
If Month(Range("B" & n)) = suiv Then
Range("B" & n).Select
Exit For
End If
Next
ActiveWindow.ScrollRow = Selection.Row
End Sub
----------------
Sub Vers_premier_jour_mois_precedent()
' Passage de mois en mois en remontant
' Touche de raccourci du clavier: Ctrl+P
Cells(ActiveCell.Row, 2).Select
If Selection.Column <> 2 Then Exit Sub
x = Month(Selection.Value)
suiv = x - 1
If suiv = 0 Then suiv = 13
For n = 4 To Range("B" & Rows.Count).End(xlUp).Row
If Month(Range("B" & n)) = suiv Then
Range("B" & n).Select
Exit For
End If
Next
ActiveWindow.ScrollRow = Selection.Row
End Sub
--------------------
Sub Vers_premier_jour_annee_suivante()
' Passage d'année en année en descendant
Cells(ActiveCell.Row, 2).Select
If Selection.Column <> 2 Then Exit Sub
x = Year(Selection.Value)
suiv = x + 1
'If suiv = 13 Then suiv = 1
For n = Selection.Row To Range("B" & Rows.Count).End(xlUp).Row
If Year(Range("B" & n)) = suiv Then
Range("B" & n).Select
Exit For
End If
Next
ActiveWindow.ScrollRow = Selection.Row
End Sub
----------------------
Sub Vers_premier_jour_annee_precedente()
' Passage d'année en année en remontant
' Touche de raccourci du clavier: Ctrl+P
Cells(ActiveCell.Row, 2).Select
If Selection.Column <> 2 Then Exit Sub
x = Year(Selection.Value)
Cells(ActiveCell.Row, 2).Select
suiv = x - 1
If suiv = 0 Then suiv = 13
For n = 4 To Range("B" & Rows.Count).End(xlUp).Row
If Year(Range("B" & n)) = suiv Then
Range("B" & n).Select
Exit For
End If
Next
ActiveWindow.ScrollRow = Selection.Row
End Sub