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.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
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?
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,517
Members
449,088
Latest member
RandomExceller01

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