Loading New Userform According To The Clicked Listbox Item

Excel VBA Loading New Userform When Listbox Item Clicked 

         
         ✅ We used a template that we did earlier (Filtering On Listbox And Copying Filtered Data) in this study.



         When any item of listbox clicked,another userform opens. The opened userform's text boxes are populated based on listbox clicked item value .

VBA codes that supply the loading of the userform and the filling of the text boxes when double-clicking on the listbox item :

Private Sub ListBox2_DblClick (ByVal Cancel As MSForms.ReturnBoolean)
Load UserForm2
UserForm2.TextBox1 = UserForm1.ListBox2.List(UserForm1.ListBox2.ListIndex, 0)
UserForm2.TextBox2 = UserForm1.ListBox2.List(UserForm1.ListBox2.ListIndex, 1)
UserForm2.TextBox3 = UserForm1.ListBox2.List(UserForm1.ListBox2.ListIndex, 2)
UserForm2.TextBox4 = UserForm1.ListBox2.List(UserForm1.ListBox2.ListIndex, 3)
UserForm2.TextBox5 = UserForm1.ListBox2.List(UserForm1.ListBox2.ListIndex, 4)
UserForm2.TextBox6 = UserForm1.ListBox2.List(UserForm1.ListBox2.ListIndex, 5)
UserForm2.TextBox7 = UserForm1.ListBox2.List(UserForm1.ListBox2.ListIndex, 6)
UserForm2.TextBox8 = VBA.Format(UserForm1.ListBox2.List(UserForm1.ListBox2.ListIndex, 7), "#,##.00")
UserForm2.TextBox9 = VBA.Format(UserForm1.ListBox2.List(UserForm1.ListBox2.ListIndex, 8), "dd.mm.yyyy")
UserForm2.TextBox10 = UserForm1.ListBox2.List(UserForm1.ListBox2.ListIndex, 0)
Unload UserForm1
UserForm2.Show
End Sub
....

✅ In the newly loaded userform, modification and deletions can be made for the listbox item.


7 comments:

  1. please suggest how to download the file

    ReplyDelete
    Replies
    1. - Click http://adf.ly/1dDv2T
      - The "Skip Ad" button appears in the upper right corner.You will be redirected to "google.com/drive" when you press this button.
      - On the top of page(google.com/drive),there is an arrow pointing down.Click it and download file.

      Delete
  2. any idea how to download the file

    ReplyDelete
  3. Hi Merkez. Your tuto is awesome. This helps me enormously in my learning of the VBA Excel programming language.

    I've been trying to figure out how you can change the mouse cursor in the fly over command buttons. But without success because I would like to do the same in the labels. Can you give the tip on how to read the cur files if you like?

    Yours,

    Thank you...

    ReplyDelete
  4. Thank you a lot, very interesting.
    What if I would to copy the value of listbox1 (one row, 7 columns) in listbox2 in userform2?

    ReplyDelete
  5. Sir please send me this file..
    anand.proficon@gmail.com

    ReplyDelete
  6. Very helpful tutorial. Learned a lot. Thank you.

    ReplyDelete