ryancgarrett
Board Regular
- Joined
- Jun 18, 2011
- Messages
- 122
I'm trying to create a function that will function similar to vlookup, but will replace the value instead of return it. The other caveat is there are multiple strings to be searched and replaced within a single cell:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]F[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD]Lookup Table[/TD]
[TD][/TD]
[TD][/TD]
[TD]String[/TD]
[TD][/TD]
[TD]Result[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD]Chevy[/TD]
[TD]A[/TD]
[TD][/TD]
[TD]Chevy,Dodge[/TD]
[TD][/TD]
[TD]A,B[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD]Dodge[/TD]
[TD]B[/TD]
[TD][/TD]
[TD]Chevy,Toyota,Dodge[/TD]
[TD][/TD]
[TD]A,R,B[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD]Toyota[/TD]
[TD]R[/TD]
[TD][/TD]
[TD]Toyota,Dodge[/TD]
[TD][/TD]
[TD]R,B[/TD]
[/TR]
</tbody>[/TABLE]
I'm thinking something along the lines of =LookReplace(StringCell,LookupTable,LookupResultColumn), i.e. in the table above Cell F2 would contain =LookupReplace(D2,A1:B4,2)
I know I need to use the split function to split the strings and work with the individual strings, but I'm lost as to the lookup portion.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]F[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD]Lookup Table[/TD]
[TD][/TD]
[TD][/TD]
[TD]String[/TD]
[TD][/TD]
[TD]Result[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD]Chevy[/TD]
[TD]A[/TD]
[TD][/TD]
[TD]Chevy,Dodge[/TD]
[TD][/TD]
[TD]A,B[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD]Dodge[/TD]
[TD]B[/TD]
[TD][/TD]
[TD]Chevy,Toyota,Dodge[/TD]
[TD][/TD]
[TD]A,R,B[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD]Toyota[/TD]
[TD]R[/TD]
[TD][/TD]
[TD]Toyota,Dodge[/TD]
[TD][/TD]
[TD]R,B[/TD]
[/TR]
</tbody>[/TABLE]
I'm thinking something along the lines of =LookReplace(StringCell,LookupTable,LookupResultColumn), i.e. in the table above Cell F2 would contain =LookupReplace(D2,A1:B4,2)
I know I need to use the split function to split the strings and work with the individual strings, but I'm lost as to the lookup portion.