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.
 

Some videos you may like

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Watch MrExcel Video

Forum statistics

Threads
1,108,970
Messages
5,525,957
Members
409,673
Latest member
Riseee

This Week's Hot Topics

Top