Xin chào mng,
Em có 1 vấn đề sau mong mng giúp đỡ :
- Em muốn khi mình chọn giá trị ở cột First Name (trong Userform1) thì tự động Last Name sẽ nhận giá trị ở cột tương ứng.
Đây là đoạn Code :
Private Sub ComboBox1_Change()
Dim i As Long
Dim lastrow As Long
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
lastrow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To lastrow
If Val(Me.ComboBox1.Value) = ws.Cells(i, "A") Then
Me.TextBox1.Value = ws.Cells(i, "B").Value
End If
Next i
End Sub
Em cảm ơn

Em có 1 vấn đề sau mong mng giúp đỡ :
- Em muốn khi mình chọn giá trị ở cột First Name (trong Userform1) thì tự động Last Name sẽ nhận giá trị ở cột tương ứng.
Đây là đoạn Code :
Private Sub ComboBox1_Change()
Dim i As Long
Dim lastrow As Long
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
lastrow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To lastrow
If Val(Me.ComboBox1.Value) = ws.Cells(i, "A") Then
Me.TextBox1.Value = ws.Cells(i, "B").Value
End If
Next i
End Sub
Em cảm ơn
