Voilà je voudrais savoir comment limiter à un chiffre par case et quand je rentre un chiffre j'aimerais que le curseur se positionne d'office sur la case suivante. merci à vous.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Application.MoveAfterReturn = True
Application.MoveAfterReturnDirection = xlToRight
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A9:K9,M9:N9")) Is Nothing Or Target.Count > 1 Then Exit Sub
If Target = "" Then Exit Sub
Application.EnableEvents = False
Target = Left(Target, 1)
If Target.Address <> "$N$9" Then Target.Offset(0, 1 - (Target.Address = "$K$9")).Select
Application.EnableEvents = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A9:K9,M9:N9")) Is Nothing Or Target.Count > 1 Then Exit Sub
If Target = "" Then Exit Sub
Application.EnableEvents = False
[COLOR="Red"]If Not IsNumeric(Target) Or Len(Target) > 1 Then Application.Undo: GoTo 1[/COLOR]
If Target.Address <> "$N$9" Then Target.Offset(0, 1 - (Target.Address = "$K$9")).Select
1 Application.EnableEvents = True
End Sub
If Not IsNumeric(Target) Or Len(Target) > 1 Then Application.Undo: MsgBox "Un chiffre et un seul !", 48: GoTo 1
Private Sub Worksheet_Change(ByVal Target As Range)
[COLOR="Red"]Application.EnableEvents = False
If Not Intersect(Target, Range("L9")) Is Nothing Then Range("L9") = "-"[/COLOR]
If Intersect(Target, Range("A9:K9,M9:N9")) Is Nothing Or Target.Count > 1 Then GoTo 1
If Target = "" Then GoTo 1
If Not IsNumeric(Target) Or Len(Target) > 1 Then Application.Undo: MsgBox "Un chiffre et un seul !", 48: [COLOR="Red"]SendKeys "{F2}":[/COLOR] GoTo 1
If Target.Address <> "$N$9" Then Target.Offset(0, 1 - (Target.Address = "$K$9")).Select
1 Application.EnableEvents = True
End Sub
Mon problème est que l'affectation de touche marche avec le clavier, mais pas avec le pavé numérique (le code pour ces touches ne figurent pas dans l'aide , et KeyPress utilisé dans un USF renvoi le mëme code ASCII ).
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect(Target, Range("L9")) Is Nothing Then Range("L9") = "-"
If Intersect(Target, Range("A9:K9,M9:N9")) Is Nothing Or Target.Count > 1 Then GoTo 1
If Target = "" Then GoTo 1
[COLOR="Red"]If Application.CountBlank(Range("A9", Target)) Then Application.Undo: Rows(9).SpecialCells(xlBlanks)(1).Select: SendKeys "{F2}": GoTo 1[/COLOR]
If Not IsNumeric(Target) Or Len(Target) > 1 Then Application.Undo: MsgBox "Un chiffre et un seul !", 48: SendKeys "{F2}": GoTo 1
If Target.Address <> "$N$9" Then [COLOR="Red"]Rows(9).SpecialCells(xlBlanks)(1)[/COLOR].Select
1 Application.EnableEvents = True
End Sub
Quand je rentre un chiffre dans une case est-ce possible sans appuyer sur entrée que le curseur se place automatiquement sur la case d'à coté ? Et pour l'endroit du trait d'union pareil.