Hi guys,
I need to concatenate the content of 3 cells using the separator "-" but only when cells are non empty
The custom function I'm trying to create would look like this :
The function would be used like this :
=ConcatWithSep("-",B2,C2,D2)
The function would produce the following results :
<tbody> </tbody>
<tbody>
</tbody>
I would very much appreciate any and all help and insights into this problem.
Many thanks,
Alex
I need to concatenate the content of 3 cells using the separator "-" but only when cells are non empty
The custom function I'm trying to create would look like this :
Code:
Function ConcatWithSep(Sep As String, Str1 As String, Str2 As String, Str3 As String) As String
...
End Function
=ConcatWithSep("-",B2,C2,D2)
The function would produce the following results :
Case # | String 1 | String 2 | String 3 | FunctionResult | ResultString lenght |
1 | X | Y | Z | X-Y-Z | 5 |
2 | X | Y | | X-Y | 3 |
3 | X | | Z | X-Z | 3 |
4 | | Y | Z | Y-Z | 3 |
5 | X | | | X | 1 |
6 | | Y | | Y | 1 |
7 | | | Z | Z | 1 |
8 | | | | |
<tbody> </tbody>
Case # | String 1 | String 2 | String 3 | Function Result | Result String lenght |
1 | X | Y | Z | X-Y-Z | 5 |
2 | X | Y | | X-Y | 3 |
3 | X | | Z | X-Z | 3 |
4 | | Y | Z | Y-Z | 3 |
5 | X | | | X | 1 |
6 | | Y | | Y | 1 |
7 | | | Z | Z | 1 |
8 | | | | | 0 |
<tbody>
</tbody>
I would very much appreciate any and all help and insights into this problem.
Many thanks,
Alex
Last edited: