Having Issue with Offset

Godrik

New Member
Joined
Jan 17, 2017
Messages
1
I have 2 textboxs. The first one is the name of a restaurant. I have a list of restaraunts and their phone numbers. If you type in the name of the restaruant in textbox1 I want the phone number displayed in textbox2.

Here's what code I'm trying:

Code:
Lunch = TextBox1.Value
Set FoundRange = Sheets("Sheet2").Cells.Find(what:=Lunch, LookIn:=xlValues, Lookat:=xlWhole)
TextBox2.Text = FoundRange.Offset(0, 1)

When I run, TextBox2 remains blank.

So I tried the following code:
Code:
Lunch = TextBox1.Value
Set FoundRange = Sheets("Sheet2").Cells.Find(what:=Lunch, LookIn:=xlValues, Lookat:=xlWhole)
TextBox2.Text = FoundRange.

TextBox2 displays the same info as TextBox1. I want TextBox 2 to display the info in the cell that is one cell to the right of what is displayed in TextBox1.


Can anyone offer assistance?

Thank you.
 

Some videos you may like

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

StephenCrump

MrExcel MVP
Joined
Sep 18, 2013
Messages
4,121
Office Version
  1. 365
Platform
  1. Windows
Welcome to the Forum!

If your code works correctly for FoundRange, then I can't see any reason it won't work for FoundRange.Offset(0,1)

- Are you sure the value is non-blank?

- Is there perhaps more than one occurrence of Lunch in Sheet2 (you're searching the whole sheet). If so, are you perhaps finding an occurrence without a phone number one cell to the right?
 

Watch MrExcel Video

Forum statistics

Threads
1,128,089
Messages
5,628,609
Members
416,327
Latest member
Chimay

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
Top