Searching cells and populate listbox with results (userform)

Wicked_

Board Regular
Joined
Jun 5, 2018
Messages
81
Hi.
I've tried many different codes from different peoples, to make my search function to work, but with no hope, so i will be asking here.

So, what i want is this:

In A1, B1 and C1, i got different text (A1 = Tool ID: , B1 = Programs, C1 = Ordre)

and in the A column, i got different Tool ID's (example 500,501,502,503 etc etc)
and in the B column, i got program numbers
and in the C column, i got ordre numbers.

Then in the userform, i got a textbox and a listbox.
Within the textbox1, i want textbox1_change and when i type a number, it will show the result associated with the tool ID.

Example: If i got 100 Tool ID's and two of them got the tool id 500, and i search for 500, it will show these two results, with the tool id (500), and program number and ordre number.

I also use RowSource (name manager) with the code
VBA Code:
=OFFSET('Maskin 51'!$A$2;0;0; COUNTA('Maskin 51'!$A:$A)-1;5)
, to try to get the "bar" in the listbox to show "tool ID, program and ordre.

Anyone that can help me with this search and show result code?

If my explanation sucks, please ask, and i will try to explain better.

Thanks :)
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
So let me see if I have this correct.
On your Userform you have a TexBox Named Textbox1

And you have a Listbox named Listbox1

And when you enter a value in Textbox1 you want to search Column 1 of the active sheet for the value you entered in Textbox1

So if you enter "500" In Textbox1 you want to search Column A for the value "500"
And if found in Range("A14" put the value in Range("A14") into the listbox And the Value In Range("B14") in the Listbox and the value in range C14 into the listbox
And there may be more then one "500"

And you have what is know as a Multicolumn listbox true?
You would need what is known as a Multicolumn ListBox
Or I can just write that into the code.

And you really do not need Rowsource

I can write that into the code.
The code will be told to look down Column A of active sheet till it finds no more values in column A

I really do not know how to read your RowSource Code.
I never use Rowsource

If I understand we just want to search the active sheet column A for the Value in Textbox1

So do I understand your needs correctly?
And why do you think you need Rowsource. Maybe you know something I do not know.
 
Upvote 0
Hi.

This is all correct :)
About the RowSource, i have never used it before either, but i thought it was needed for the "header" in the listbox, but if you can code it in, im all happy :)
 
Upvote 0
Hi.

This is all correct :)
About the RowSource, i have never used it before either, but i thought it was needed for the "header" in the listbox, but if you can code it in, im all happy :)
Header in the listbox?
What is a Listbox Header?
 
Upvote 0
Hi, i mean like this screenshot i googled.

hqdefault.jpg

Where it sais "OrderDate" "Region" etc
 
Upvote 0
Ok. So I have that knowledge now.
I never like to run scripts where the script runs when someone enters a value in a TextBox
Because what happens is if you want to enter "500" the script starts running immediately when you enter 5
If does not wait till you enter 500

How about this:
You enter 500 into Textbox1 and then press a button to run the script

Would that work?
 
Upvote 0
OK I see your image.
You said you were going to enter the search value in a Textbox.
I see no Textbox in this image. That looks like a Combobox and I see a button.
Or is this not a exact image of your userform
 
Upvote 0
This image is not mine, just found one while googling to show what i meant :)
Pressing a search button to search is totally fine :)
 
Upvote 0
So maybe we need RowSource then if that's what it does.
Explain to me what is RowSource looking at?
Is your sheet named Maskin 51
=OFFSET('Maskin 51'!$A$2;0;0; COUNTA('Maskin 51'!$A:$A)-1;5)
If it works then I will include that.
 
Upvote 0

Forum statistics

Threads
1,215,343
Messages
6,124,394
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top