Hi all,
I am using a UDF from njimack to achieve the following result in Excel 2013.
[TABLE="class: cms_table_grid, width: 500, align: center"]
<tbody>[TR]
[TD]Column 1[/TD]
[TD]Column 2[/TD]
[TD]Column 3[/TD]
[TD]Formula result[/TD]
[/TR]
[TR]
[TD]1st[/TD]
[TD]2nd[/TD]
[TD]3rd[/TD]
[TD]1st, 2nd, 3rd[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3rd[/TD]
[TD]3rd[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
This is his code.
This gives a fantastic result. However I wanted to improve it a bit. Instead of getting the result as "1st, 2nd, 3rd" I want the last comma to change to a "&".
So the desired result would be this. "1st, 2nd & 3rd" OR "1st & 2nd". You get the gist.
Any help is extremely appreciated. Thank you guys.
I am using a UDF from njimack to achieve the following result in Excel 2013.
[TABLE="class: cms_table_grid, width: 500, align: center"]
<tbody>[TR]
[TD]Column 1[/TD]
[TD]Column 2[/TD]
[TD]Column 3[/TD]
[TD]Formula result[/TD]
[/TR]
[TR]
[TD]1st[/TD]
[TD]2nd[/TD]
[TD]3rd[/TD]
[TD]1st, 2nd, 3rd[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3rd[/TD]
[TD]3rd[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
This is his code.
Code:
[COLOR=#333333]Function Concatenate_Range(myrange As Range, Optional myDelimiter As String)[/COLOR]Dim Cell As Range
Application.Volatile
For Each Cell In myrange
If Len(Cell.Value) > 0 Then
Concatenate_Range = Concatenate_Range & Cell & myDelimiter
Else: Concatenate_Range = Concatenate_Range
End If
Next Cell
If Len(myDelimiter) > 0 Then Concatenate_Range = Left(Concatenate_Range, Len(Concatenate_Range) - Len(myDelimiter))
[COLOR=#333333]End Function[/COLOR]
This gives a fantastic result. However I wanted to improve it a bit. Instead of getting the result as "1st, 2nd, 3rd" I want the last comma to change to a "&".
So the desired result would be this. "1st, 2nd & 3rd" OR "1st & 2nd". You get the gist.
Any help is extremely appreciated. Thank you guys.