Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help:Find and Display
Hi! I have a *form*, 2 textbox (*textbox1 *and *text box2*), and a *button*. worksheet has *column A* and *Column B*. ex. column A column B Item1 1,000 i want the *button* to search *column A* with the data i've entered in *textbox1* and displays the corresponding value in *column B* in *textbox2*. -- kenrose08 ------------------------------------------------------------------------ kenrose08's Profile: http://www.excelforum.com/member.php...o&userid=22317 View this thread: http://www.excelforum.com/showthread...hreadid=570977 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help:Find and Display
Have a look at the Find Method of the Range Object. There's an
example in the VBA help showing how to use it. This could be useful!: Private Sub cmdSearch_Click() Set searchRng = Sheets(1).Range("A:A") With searchRng Set resultRng = .Find(TextBox1.Text, LookIn:=xlValues) TextBox2.Text = TextBox2.Text & Sheets(1).Range("B" & result.Row).Value & vbCrLf |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help:Find and Display
TextBox2.Text = TextBox2.Text & Sheets(1).Range("B" & result.Row).Value & vbCrLf spotted a typo above: result.Row should be resultRng.Row |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help:Find and Display
Thank you Sir, this is so much help. *just another question*. what if the data i want to search is not in the list, how do i code it? *thanks*! Tony James Wrote: TextBox2.Text = TextBox2.Text & Sheets(1).Range("B" & result.Row).Value & vbCrLf spotted a typo above: result.Row should be resultRng.Row -- kenrose08 ------------------------------------------------------------------------ kenrose08's Profile: http://www.excelforum.com/member.php...o&userid=22317 View this thread: http://www.excelforum.com/showthread...hreadid=570977 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help:Find and Display
Insert the following in the If statement:
Else MsgBox TextBox1.Text & " not found." |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help:Find and Display
thanks but how do i start the if statement? i really dont know how and where to code it -- kenrose08 ------------------------------------------------------------------------ kenrose08's Profile: http://www.excelforum.com/member.php...o&userid=22317 View this thread: http://www.excelforum.com/showthread...hreadid=570977 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Find And Display Surname | Excel Worksheet Functions | |||
Find one character or another and display | Excel Worksheet Functions | |||
Find max # and display name | Excel Discussion (Misc queries) | |||
Find and display information | Excel Programming | |||
Find display the result | Excel Programming |