Re : Changer Couleur TextBox et enregistrer ds feuille
Carcharodon Carcharias, Robert, Le Fil,
Dans mon USF,
J'ai 8 Combo avec Un CheckBox qui me permet lorsque clické de changer la couleur de l'écriture via le code:
Private Sub CheckBox15_Click()
If CheckBox15 = True Then
ComboBox1.ForeColor = &HC0&
ComboBox2.ForeColor = &HC0&
ComboBox3.ForeColor = &HC0&
ComboBox4.ForeColor = &HC0&
ComboBox5.ForeColor = &HC0&
ComboBox6.ForeColor = &HC0&
ComboBox7.ForeColor = &HC0&
ComboBox8.ForeColor = &HC0&
Else
If CheckBox15 = False Then
ComboBox1.ForeColor = &H80000008
ComboBox2.ForeColor = &H80000008
ComboBox3.ForeColor = &H80000008
ComboBox4.ForeColor = &H80000008
ComboBox5.ForeColor = &H80000008
ComboBox6.ForeColor = &H80000008
ComboBox7.ForeColor = &H80000008
ComboBox8.ForeColor = &H80000008
End If
End If
End Sub
Si Clické, en Rouge, sinon, en Noir,
Ensuite, Mon Command me permet de copier toutes les combo et TextBox dans une base de données par colonne, via le code suivant:
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Sheets("Base de Données acheteurs").Activate
Dim NomDeFeuilEnCours$, lidep1 As Long, cellule As Range
NomDeFeuilEnCours = "Base de Données acheteurs"
Dim Ctrl As Control
Dim Valeur As String
Dim Vr As Byte, Fx As Byte
For Each Ctrl In Me.Controls
If TypeOf Ctrl Is MSForms.CheckBox Then
If Ctrl.Value = True Then
Valeur = Valeur & Ctrl.Name & " = True " & Chr(10)
Vr = Vr + 1
Else
Valeur = Valeur & Ctrl.Name & " =False " & Chr(10)
Fx = Fx + 1
If CréerFicheAcquéreur.TextBox9.Value = "" Then
MsgBox " Le Nom de l'acquéreur est obligatoire . "
Exit Sub
End If
End If
End If
Next
li = Range("A6000").End(xlUp).Row
li = li + IIf(li < 4, 2, 1) ' à cause des lignes fusionnées !
Cells(li, 1) = TextBox9.Value
Cells(li, 2) = TextBox10.Value
Cells(li, 2) = TextBox10.Value
Cells(li, 3) = TextBox5.Value
Cells(li, 4) = TextBox24.Value
Cells(li, 5) = TextBox25.Value
Cells(li, 6) = TextBox22.Value
Cells(li, 7) = IIf(OptionButton15, "Tous secteurs", "")
Cells(li, 8) = ComboBox1.Value
Cells(li, 9) = ComboBox2.Value
Cells(li, 10) = ComboBox3.Value
Cells(li, 11) = ComboBox4.Value
Cells(li, 12) = ComboBox5.Value
Cells(li, 13) = ComboBox6.Value
Cells(li, 14) = ComboBox7.Value
Cells(li, 15) = ComboBox8.Value
Cells(li, 16) = IIf(CheckBox1, "MDV", "") & IIf(CheckBox2, "Appart", "") & IIf(CheckBox3, "Villa", "") & IIf(CheckBox4, "Mas", "") & IIf(CheckBox5, "Terrain", "")
Cells(li, 17) = TextBox2.Value
Cells(li, 18) = IIf(CheckBox11, "Oui", "")
Cells(li, 19) = TextBox3.Value
Cells(li, 20) = TextBox4.Value
Cells(li, 21) = IIf(OptionButton1, "Oui", "")
Cells(li, 22) = IIf(OptionButton2, "Oui", "")
Cells(li, 23) = TextBox7.Value
Cells(li, 24) = TextBox8.Value
Cells(li, 25) = IIf(CheckBox6, "Oui", "")
Cells(li, 26) = IIf(CheckBox7, "Oui", "")
Cells(li, 27) = IIf(CheckBox8, "Oui", "")
Cells(li, 28) = IIf(CheckBox9, "Oui", "")
Cells(li, 29) = IIf(OptionButton11, "Cuisine US", "")
Cells(li, 29) = IIf(OptionButton10, "Cuisine séparée", "")
Cells(li, 30) = IIf(CheckBox10, "Oui", "")
Cells(li, 31) = TextBox20.Value
Cells(li, 32) = TextBox21.Value
Cells(li, 33) = IIf(CheckBox12, "Oui", "")
Cells(li, 34) = IIf(CheckBox13, "Oui", "")
Cells(li, 35) = TextBox23.Value
Cells(li, 36) = IIf(CheckBox14, "Oui", "")
Cells(li, 37) = TextBox19.Value
End With
Call trierzonedetriacheteurs
Call calculnombrefichesacheteurs
Unload Me
Application.ScreenUpdating = True
SaisirPije.Hide
Accueil.Show
CréerFicheAcquéreur.Hide
Accueil.Show
End Sub
Ma difficulté est de traduire dans ce dernier code non seulement le .Value, qui fonctionne bien, mais pour les 8 Combo, la couleur de l'écriture.....
J'ai bien testé ce que tu m'as proposé, mais sans succès.
Voulez vous un fichier exemple ou arrive tu à mieux cerner ma demande!
en tout cas merci à vous tous pour votre aide.
Bonne nuit si ce n'est déjà le cas ou à tte sur le Fil