Search

Create dependent combo boxes in excel user form with vba-sample code

Like what I do? Donate
Did I help you? Did one of my tutorials save you sometime? 
You can say thank you by buying me a cup of coffee, I go through a lot of it.
Help keep Greater Good resources free for everyone. Please donate today. 




This page is not monitored so for questions please comment on the youtube video page. For suggestions email vbaa2z.team@gmail.com



Option Explicit

Private Sub ComboBox1_Change()

'-----------------------------
'Thanks for downloading the code. 
'Please visit our channel for a quick explainer on this code.
'Feel free to update the code as per your need and also share with your friends.
'Channel: Youtube.com/vbaa2z
'Download free codes from http://vbaa2z.blogspot.com
'Autor: L Pamai (vbaa2z.team@gmail.com)
'-----------------------------

    'email
    Me.TextBox1.Value = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, Sheets("DataSample").Range("B2:N28"), 10, 0)
    
    'address
    Me.TextBox2.Value = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, Sheets("DataSample").Range("B2:N28"), 4, 0)
    
End Sub

Private Sub TextBox3_Change()

End Sub

Private Sub UserForm_Initialize()

'-----------------------------
'Thanks for downloading the code. 
'Please visit our channel for a quick explainer on this code.
'Feel free to update the code as per your need and also share with your friends.
'Channel: Youtube.com/vbaa2z
'Download free codes from http://vbaa2z.blogspot.com
'Autor: L Pamai (vbaa2z.team@gmail.com)
'-----------------------------

Dim i As Long

For i = 2 To 28
        Me.ComboBox1.AddItem Cells(i, 2)
Next

Me.TextBox3.Visible = False


End Sub

No comments:

Post a Comment

Note: only a member of this blog may post a comment.