I have an Excel document which consist of different sheets. In one sheet I have column:
| text column |
|#test2,#test3,#test1|
|#test2, #test1 |
|#test1 |
In another sheet I have a mapping for the values:
|some column| value |
|#test2 | Value2 |
|#test1 | Value1 |
|#test3 | Value3 |
So I need to have the result:
| text column |
| Value2, Value3, Value1|
| Value2, Value1 |
| Value1 |
Is this possible to get this by Excel Worksheet functions?
I tried to explode the data but I can have undefined quantity of values in the concrete cell. Also tried to use VLOOKUP
but I don't have an idea how to use this because I need to split the values before VLOOKUP
.
Can you help me? Thank you.
Because you need some form of iteration, i.e. split a value, perform an operation on each item and rejoin the items - it is unlikely there is a way to do this with Excel functions. If you are happy to use VBA then the user-defined function is quite straight-forward:
E.g.
I think you will find the SUBSTITUTE function will achieve what you are looking for:
You could nest each SUBSTITUTE but I think that would end up being quite difficult to read and maintain.
My suggested approach of implementing would be, as per the image attached, to incrementally perform the substitution. So starting with the orignal text in column A substitute #test1 for value1 in column B and then substitue #test2 in the text now in column B with a formula in column C etc.
substitute example