Searching Sheet2 with Text from Sheet1

nzepeda

Board Regular
Joined
Nov 11, 2010
Messages
58
I am going to attempt to write a macro that will be searching Sheet2, which has the name of different locations down along column A22 to A375 and 2 columns over has a corresponding Code for location. To search Sheet2 I will need to use a string from Sheet1. Sheet1 along B5 to H5 will have the strings I will be using.

Somehow I want to write a macro that will assign the text in B5 to a string variable. It must then use this variable to search Sheet2 for the text, once found, offset 2 columns over and copy the code. After this paste this code into Sheet3 down along A3.

Where this will get tricky is that the text from Sheet1 will not always be found right away in Sheet2, sometimes this text will lead with 1 to 3 characters followed by a space. I will have to have the code take this into account, by having it loop somehow if not found the first time, to shift over 1 space at a time and search again.

There may also be similar locations on Sheet2, but which have different codes. So if multiple locations match the string I must have it bring up a userform of some sort that will have the locations to have me choose which is the proper 1.

Any help would be much appreciated. Will be working on this for the next few days. If needed I will try to post examples of how the sheets may look.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,216,380
Messages
6,130,282
Members
449,570
Latest member
TomMacca52

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