Displaying data from value of text box

TheMatrixReloaded

New Member
Joined
May 6, 2002
Messages
29
The phone number text box and address text box are on the same form. The address needs to be displayed as soon as the phone number is entered. If the value of my phone number in the text box, equals a phone number in another sheet (Phone Table), then the address should display in the address text box below the phone number text box.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Something like this (note: I've not tested this and I'm just typing this into the forum, so if it works first time, that's amazing) I've also called your textboxes - txtPhone and txtAddress respectively and I've assume that the Phone number is in the column to the right of the address. i.e. if Phone number is in Column A, Address is in Column B:

<pre>
Dim oRange As Range

Set oRange = Sheets("Phone Table").UsedRange.Find(What:=txtPhone.Text)

If Not oRange is Nothing then
txtAddress.Text = oRange.Offset(1,0).Value
End if</pre>

Put this code on a button click event or something.

If you need any help just repost.

HTH
 
Upvote 0

Forum statistics

Threads
1,214,387
Messages
6,119,225
Members
448,877
Latest member
gb24

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