Modification d'un code

Bonjour,

Voila j'ai un combobox sur ma feuille qui me renvoie les information dans trois textbox situer sur ma feuille qui fonctionne tres bien

J'aimerais que les valeurs ne soit pas sur les trois textbox mais da les cellules "C2, C3, et C4".

Voici mon code auquel on peut modifier.

Private Sub ComboBox1_Click()

Call Oter_Couleur
n = Feuil2.Cells(ComboBox1.ListIndex + 2, 1)
If n = "" Then Exit Sub
If Left(n, 4) = "EU0" Then
n = Right(n, 1)

Else
n = Right(n, 2)
End If

ActiveSheet.Shapes("EU-" & n).Select
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 3

ActiveSheet.Shapes("TextBox95").Select

Selection.Caption = "Département :  " & Feuil2.Cells(ComboBox1.ListIndex + 2, 3) & "  " & Feuil2.Cells(ComboBox1.ListIndex + 2, 4)
ActiveSheet.Shapes("Text Box 97").Select
Selection.Caption = "Région :  " & Feuil2.Cells(ComboBox1.ListIndex + 2, 4) & "  " & Feuil2.Cells(ComboBox1.ListIndex + 3, 7)
ActiveSheet.Shapes("Text Box 96").Select
Selection.Caption = "Code Postal :  " & Feuil2.Cells(ComboBox1.ListIndex + 2, 2) & "  " & Feuil2.Cells(ComboBox1.ListIndex + 3, 7)
[A1].Select

'Rend invisible la shape nommer Comments
ActiveSheet.Shapes("Comments").Visible = False
End Sub

Je vous remercie d'avance

Cordialement

Max

Bonjour,

Ne disposant pas de fichier, je n'ai pas testé le code.

A adapter si nécessaire :

Private Sub ComboBox1_Click()
    Call Oter_Couleur
    n = Feuil2.Cells(ComboBox1.ListIndex + 2, 1)
    If n = "" Then Exit Sub
    If Left(n, 4) = "EU0" Then
        n = Right(n, 1)
    Else
        n = Right(n, 2)
    End If
    ActiveSheet.Shapes("EU-" & n).ShapeRange.Fill.ForeColor.SchemeColor = 3
    ActiveSheet.Range("C2") = "Département :  " & Feuil2.Cells(ComboBox1.ListIndex + 2, 3) & "  " & Feuil2.Cells(ComboBox1.ListIndex + 2, 4)
    ActiveSheet.Range("C3") = "Région :  " & Feuil2.Cells(ComboBox1.ListIndex + 2, 4) & "  " & Feuil2.Cells(ComboBox1.ListIndex + 3, 7)
    ActiveSheet.Range("C4") = "Code Postal :  " & Feuil2.Cells(ComboBox1.ListIndex + 2, 2) & "  " & Feuil2.Cells(ComboBox1.ListIndex + 3, 7)
    [A1].Select
    'Rend invisible la shape nommer Comments
    ActiveSheet.Shapes("Comments").Visible = False
End Sub

A+

Bonjour Frangy

Je te remerci mais j'ai un message d'erreur sur la ligne suivante;

ActiveSheet.Shapes("EU-" & n).ShapeRange.Fill.ForeColor.SchemeColor = 3

Message, Propriete ou methode non gérée par cet objet

Merci

@+

Replace le code initial

ActiveSheet.Shapes("EU-" & n).Select
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 3

et surtout, ne joints pas un ficher, ça rendrait les tests trop faciles

A+

Re,

Je te remercie sa fonctionne nickel.

Mon fichier et trop gros pour l'envoyer sinon cétait avec plaisir.

Bonne soirée et merci encore

Max

Rechercher des sujets similaires à "modification code"