Forum

Search and Display ...
 
Notifications
Clear all

Search and Display UserForm

2 Posts
2 Users
0 Reactions
184 Views
(@salvador917)
Posts: 1
New Member
Topic starter
 

Good Morning/Afternoon everyone, 

Hopefully someone can help me out with a VBA Macro i am having a hard time solving...Basically i have an excel that has Name, Age, Gender, City , and State in colums. I already created a userform with the following labels and textboxes but the problem im having is i am trying to make it where i create a commanbutton ( Search and Display) , input characters that are part of their last name and have it display in the textboxes according to their category. Basically for example if i type Smith or smith it will be able to identify the information and display it the other data into the text boxes or if members have same last names i can just put Smith, D as a search option. any guidance will be greatly appreciated. 

 

This is what i have so Far: 

 

Dim Name As String
Name = Trim(TextBox6.Text)
lastrow = Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row

For i = 2 To lastrow
If Worksheets("Sheet1").Cells(i, 1).Value = Name Then
TextBox1.Text = Worksheets("Sheet1").Cells(i, 1).Value
TextBox2.Text = Worksheets("Sheet1").Cells(i, 2).Value
TextBox3.Text = Worksheets("Sheet1").Cells(i, 3).Value
TextBox4.Text = Worksheets("Sheet1").Cells(i, 4).Value
TextBox5.Text = Worksheets("Sheet1").Cells(i, 5).ValueUserForm-Example.png

 
Posted : 15/11/2023 3:12 pm
(@keebellah)
Posts: 373
Reputable Member
 

Hi, I sugguest first that you attach a file with non private data file with the macros as you have it now and also tell us the Excel/Office version you're using.

 
Posted : 16/11/2023 11:14 am
Share: