Microsoft 365 Couleurs dans Textbox

Francky79

XLDnaute Occasionnel
Bonjour,

Comment récupérer les couleurs de cellules venant de mise en forme conditionnelle dans des Textboxs ?
Voir fichier joint.

Merci pour votre aide.
 

Pièces jointes

  • Couleur Textbox.xlsm
    20.3 KB · Affichages: 6
Solution
re
et si on veut simplifier le code
Code:
Sub T()
    Dim commentaire As Comment

    With Range("a" & ActiveCell.Row).Resize(, 6)
        For i = 1 To .Cells.Count
            UserForm1.Controls("TextBox" & i).Text = .Cells(i)
            If i >= 4 Then UserForm1.Controls("TextBox" & i).BackColor = .Cells(i).DisplayFormat.Interior.Color
        Next
    End With

    UserForm1.Show
End Sub

patricktoulon

XLDnaute Barbatruc
bonjour
pour recupérer la couleur appliquée par une MFC il faut utiliser le membre "DisplayFormat de l'object range

VB:
Sub T()
    Dim Lig&, commentaire As Comment
    Lig = ActiveCell.Row
    UserForm1.TextBox1.Text = ActiveCell.Value
    UserForm1.TextBox2.Text = Range("B" & Lig).Value
    UserForm1.TextBox3.Text = Range("C" & Lig).Value

    With Range("D" & Lig).Resize(, 3)
        For i = 1 To 3
            UserForm1.Controls("TextBox" & i + 3).BackColor = .Cells(i).DisplayFormat.Interior.Color
            UserForm1.Controls("TextBox" & i + 3).Value = Cells(i)
        Next
    End With

    UserForm1.Show
End Sub
 

patricktoulon

XLDnaute Barbatruc
re
et si on veut simplifier le code
Code:
Sub T()
    Dim commentaire As Comment

    With Range("a" & ActiveCell.Row).Resize(, 6)
        For i = 1 To .Cells.Count
            UserForm1.Controls("TextBox" & i).Text = .Cells(i)
            If i >= 4 Then UserForm1.Controls("TextBox" & i).BackColor = .Cells(i).DisplayFormat.Interior.Color
        Next
    End With

    UserForm1.Show
End Sub
 

Discussions similaires

Statistiques des forums

Discussions
312 211
Messages
2 086 300
Membres
103 173
dernier inscrit
Cerba95