Autres [RÉSOLU] Souligner texte VBA

un internaute

XLDnaute Impliqué
Bonjour le forum
Dans la macro ci-dessous je voudrais souligner CB: & Chq:
Voir peut-être aussi si je peux "jouer" sur l'épaisseur du trait de soulignement mais si trop compliqué ne pas "s'acharner" dessus (pour épaisseur du trait)
Merci pour vos éventuels retours
Cordialement

Mais je ne sait pas faire
VB:
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
    .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 €")
    .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 €")
    .NumberFormat = "@"
    End With
    Columns("I").AutoFit
End Sub

Private Sub TbMontant_Change()
  With Range("I" & Ligne)
    .Value = Msg & Format(Replace(Me.TbMontant, ".", ","), "#,##0.00 €")
    .NumberFormat = "@"
    End With
    Columns("I").AutoFit
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
 

TooFatBoy

XLDnaute Barbatruc
Bonjour,

A tester :
VB:
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, 4).Font.Underline = True
    .NumberFormat = "@"
    End With
    Columns("I").AutoFit
End Sub

VB:
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, 5).Font.Underline = True
    .NumberFormat = "@"
    End With
    Columns("I").AutoFit
End Sub
 

TooFatBoy

XLDnaute Barbatruc
T'es sûr que tu as bien recopié les deux macros ?



Si tu ne mets pas l'espace insécable avant le caractère ":", tu dois alors retrancher un au nombre de caractères à souligner et donc mettre respectivement 3 et 4 à la place de 4 et 5.

VB:
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
    .NumberFormat = "@"
    End With
    Columns("I").AutoFit
End Sub

VB:
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
    .NumberFormat = "@"
    End With
    Columns("I").AutoFit
End Sub
 
Dernière édition:

Discussions similaires

Réponses
17
Affichages
334

Statistiques des forums

Discussions
312 206
Messages
2 086 219
Membres
103 158
dernier inscrit
laufin