Bonjour le forum
Dans la macro ci-dessous je voudrais fermer l'userform avec Enter ou Valider
En effet je tape le montant et j'ai l'habitude de faire Enter sinon par la croix
J'ai commencé mais pas pu y arriver (mis en commentaires)
Merci pour vos éventuels retours
Option Explicit
Dim Ligne As Long
Dim Msg As String
Private Sub Opb100_Click()
Me.TbMontant.Visible = False
Me.LbMontant.Visible = False
With Range("I" & Ligne)
.Value = 1
.Characters.Font.Underline = False
.NumberFormat = "00 %"
End With
Columns("I").AutoFit
End Sub
Private Sub OpbCB_Click()
Me.TbMontant.Visible = True
Me.LbMontant.Visible = True
Msg = "CB: "
With Range("I" & Ligne)
.Value = Msg & Format(Replace(Me.TbMontant, ".", ","), "#,##0.00 €")
.Characters(1, 3).Font.Underline = True
.Characters(4, 100).Font.Underline = False
.NumberFormat = "@"
End With
Columns("I").AutoFit
End Sub
Private Sub OpbChèque_Click()
Me.TbMontant.Visible = True
Me.LbMontant.Visible = True
Msg = "Chq: "
With Range("I" & Ligne)
.Value = Msg & Format(Replace(Me.TbMontant, ".", ","), "#,##0.00 €")
.Characters(1, 4).Font.Underline = True
.Characters(5, 100).Font.Underline = False
.NumberFormat = "@"
End With
Columns("I").AutoFit
End Sub
Private Sub TbMontant_Change()
Dim Pos As Integer
With Range("I" & Ligne)
Pos = InStr(1, .Value, ":")
.Value = Msg & Format(Replace(Me.TbMontant, ".", ","), "#,##0.00 €")
.Characters(1, Pos).Font.Underline = True
.Characters(Pos + 1, 100).Font.Underline = False
.NumberFormat = "@"
End With
Columns("I").AutoFit
End Sub
'Private Sub TbMontant_Exit(ByVal Cancel As MSForms.ReturnBoolean)
' Unload Me
'End Sub
Private Sub TbMontant_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr(1, "0123456789.,", Chr(KeyAscii)) = 0 And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub UserForm_Initialize()
Ligne = ActiveCell.Row
Me.TbMontant.Visible = False
Me.LbMontant.Visible = False
Me.LbLigne.Caption = "Ligne " & Ligne
End Sub