Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default list all the find values


I am trying to do the following.

I have a list of names in sheet1 column b - b2:B500

I have a user form that I would like to do the following

the user can enter any part of a name into a text box and the list bo
with the names the user can choose will only have those that contai
what he just entered.

for example

a user is trying to find a customers name. The current list box the
can choose from has all names for 500 customers. To make it simpl
there will be a text box that allows them to type in any part of th
customers name and then it will repopulate the list box with th
resulting values of the search term. match case is false....

Thanks for any help...

Jos

--
jhahe
-----------------------------------------------------------------------
jhahes's Profile: http://www.excelforum.com/member.php...fo&userid=2359
View this thread: http://www.excelforum.com/showthread.php?threadid=55159

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default list all the find values



Private Sub Textbox1_Change()
Dim rng as Range, v as Variant
Dim s1 as String, s as String
Dim i as Long, l as Long
with worksheets("Data")
set rng = .Range("B2:B500")
End with
v = rng
Listbox1.clear
s1 = lcase(Textbox1.Value)
l = len(s1)
for i = 1 to 499
s = v(i,1)
if lcase(left(s,l)) = s1 then
AddItem s
end if
next i
end Sub

--
Regards,
Tom Ogilvy

"jhahes" wrote:


I am trying to do the following.

I have a list of names in sheet1 column b - b2:B500

I have a user form that I would like to do the following

the user can enter any part of a name into a text box and the list box
with the names the user can choose will only have those that contain
what he just entered.

for example

a user is trying to find a customers name. The current list box they
can choose from has all names for 500 customers. To make it simple
there will be a text box that allows them to type in any part of the
customers name and then it will repopulate the list box with the
resulting values of the search term. match case is false....

Thanks for any help...

Josh


--
jhahes
------------------------------------------------------------------------
jhahes's Profile: http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=551594


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default list all the find values


i tried the code and it gives me this error

sub or function not defined AND

AddItem is highlighted when this happens....

thanks

Josh


--
jhahes
------------------------------------------------------------------------
jhahes's Profile: http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=551594

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default list all the find values

Just a typo
Additem s

should be

ListBox1.AddItem s

I tested it with that correction and it worked fine for me. (lightly
tested).

--
Regards,
Tom Ogilvy


"jhahes" wrote:


i tried the code and it gives me this error

sub or function not defined AND

AddItem is highlighted when this happens....

thanks

Josh


--
jhahes
------------------------------------------------------------------------
jhahes's Profile: http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=551594


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default list all the find values


I like what the code does but you have to type in the whole name for it
to find matching entries.

Is there anyway that it can do this

if you type in say (joh) in the text field and it finds all the
following because they contain joh in part of the word

john smith
tom johnson
john davis
johan smith

Thanks for any help...

Josh


--
jhahes
------------------------------------------------------------------------
jhahes's Profile: http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=551594



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default list all the find values

Private Sub Textbox1_Change()
Dim rng as Range, v as Variant
Dim s1 as String, s as String
Dim i as Long, l as Long
with worksheets("Data")
set rng = .Range("B2:B500")
End with
v = rng
Listbox1.clear
s1 = lcase(Textbox1.Value)
l = len(s1)
for i = 1 to 499
s = v(i,1)
if Instr(1,s,s1,vbTextCompare) 0 then
AddItem s
end if
next i
end Sub

--
Regards,
Tom Ogilvy


"jhahes" wrote in
message ...

I like what the code does but you have to type in the whole name for it
to find matching entries.

Is there anyway that it can do this

if you type in say (joh) in the text field and it finds all the
following because they contain joh in part of the word

john smith
tom johnson
john davis
johan smith

Thanks for any help...

Josh


--
jhahes
------------------------------------------------------------------------
jhahes's Profile:

http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=551594



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find values in one list that do not appear in a second list Gwen Struve Excel Discussion (Misc queries) 1 December 23rd 08 07:40 PM
How to find values in a list of text fields [email protected] Excel Worksheet Functions 4 June 10th 08 10:43 AM
How to find the values from a list? Eric Excel Discussion (Misc queries) 3 December 1st 06 02:40 PM
How to find and list duplicate values in a list? Stefan[_6_] Excel Programming 1 May 14th 04 01:09 PM
How to find and list duplicate values in a list? Stefan[_6_] Excel Programming 1 May 14th 04 12:58 PM


All times are GMT +1. The time now is 03:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"