Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

XL 2010 Ventes clients

hema300

XLDnaute Nouveau
Bonjour
pouvez-vous m'aider
Lors de la sélection d'un nom de client spécifique dans ComboBox1
Apporte la dernière valeur répertoriée dans la feuille à textbox1
 
Solution
VB:
Private Sub ComboBox1_Change()
Dim ws2 As Worksheet
    Set ws2 = Sheets("Sheet2")
    Dim lastrow As Long
    lastrow = ws2.Cells(ws2.Rows.Count, "A").End(xlUp).Row
    Dim i As Integer
    Dim foundValue As String
    TextBox1.Value = ""
    For i = 2 To lastrow
        If ws2.Cells(i, 1).Value = ComboBox1.Value Then
            foundValue = ws2.Cells(i, 2).Value
        End If
    Next i
    TextBox1.Value = foundValue
    End Sub

hema300

XLDnaute Nouveau
VB:
Private Sub ComboBox1_Change()
Dim ws2 As Worksheet
    Set ws2 = Sheets("Sheet2")
    Dim lastrow As Long
    lastrow = ws2.Cells(ws2.Rows.Count, "A").End(xlUp).Row
    Dim i As Integer
    Dim foundValue As String
    TextBox1.Value = ""
    For i = 2 To lastrow
        If ws2.Cells(i, 1).Value = ComboBox1.Value Then
            foundValue = ws2.Cells(i, 2).Value
        End If
    Next i
    TextBox1.Value = foundValue
    End Sub
 

Discussions similaires

Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…