PDA

View Full Version : dynamic search content



asddsa88
03-07-2010, 07:28 AM
scenario:

column A with a list of names

column B with a list of names

1)I need to compare list B with A

2)if the text value of a cell from column B matches the text value of another cell from column A

3)move 2 cells to the right of the matching cell in column A and write something



example:
(sorry for the confusing ---- signs but the forum wouldn't let me insert blank spaces...)

COLUMN A----------- COLUMN B----------- COLUMN C

mark----------------- pete
pete -------------------------------------- OK
john

the value of b1 is matching the value of a2, so the macro has to select cell a2, move 2 cells to the right (c2) and write "OK"




I am not sure if vba macros support a dynamic search input where they can get the value to be searched from a cell text value.. is this possible?

lucas
03-07-2010, 07:58 AM
will a formula work?

see attached. Formula in column C2 and drag down


=IF(OFFSET(C2,-1,-1)=OFFSET(C2,0,-2),"OK","")

asddsa88
03-07-2010, 01:14 PM
sorry for not being clear in my explaination... the contents of list B are dynamic, so there could be any name in any cell!

that's why I am looking for something that compares (maybe using the find function) for EACH cell of column B , EVERY cell of column A

quick example:

column A --------------column B--------------column C

pete ------------------annie--------------- ok
john-------------------pete
mark-------------------annie
pete-----------------------------------------ok
jamie-------------------annie

so if pete in b2 had been in b3 there wouldn't be any difference in the column C output!

the script needs to

1)take b1 text (in this case annie), search it in a1/b1/c1/d1/etc.... IF it finds a match, returns OK in column C. (in this case it wouldn't return anything)

2)take b2 text (in this case pete), search it in a1/b1/c1/d1/etc.... IF it finds a match, returns OK in column C. (in this case A1 and A4 are matching, so it returned OK twice)

3)take b3 text, search it in a1/b1/c1/d1/etc.... IF it finds a match, returns OK in column C.

and so on!