简体   繁体   中英

Search and return in Excel VBA or Formula

I am looking for returning anything that is in Bin column as shown in the picture. Basically, in the first column, it may or may not contain some signals that are in Column B. I would like to return any signals in column B as a new column and ignore any signals that are not in Column B. Any idea, what is the best way? Formula or VBA. Just to be clear, column 3 is what I want to output. Search and return signals

I found your problem to be interesting (and a bit challenging). Put this formula in the "Return" Column and copy down as needed. It will support up to seven characters in Column A.You can edit it manually if Column A exceeds this amount in the formula:

=IFERROR(IF(SEARCH(B1,A1,1)>0,B1,"")&IF(COUNTIF(B2:B$100,MID(A1,1,1))>0,MID(A1,1,1),"")&IF(COUNTIF(B2:B$100,MID(A1,2,1))>0,MID(A1,2,1),"")&IF(COUNTIF(B2:B$100,MID(A1,3,1))>0,MID(A1,3,1),"")&IF(COUNTIF(B2:B$100,MID(A1,4,1))>0,MID(A1,4,1),"")&IF(COUNTIF(B2:B$100,MID(A1,5,1))>0,MID(A1,5,1),"")&IF(COUNTIF(B2:B$100,MID(A1,6,1))>0,MID(A1,6,1),"")&IF(COUNTIF(B2:B$100,MID(A1,7,1))>0,MID(A1,7,1),""),"")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM