yesterdays
Active Member
- Joined
- Oct 8, 2014
- Messages
- 337
I'm using below code for joining multiple range(s)'s value to form a string, it work fine,
But now i need to use other formula to form the range inside it, it doesn't work anymore.
please see sample below
[TABLE="width: 256"]
<tbody>[TR]
[TD="class: xl66, width: 64"][/TD]
[TD="class: xl66, width: 64"]A[/TD]
[TD="class: xl66, width: 64"]B[/TD]
[TD="class: xl66, width: 64"]C[/TD]
[/TR]
[TR]
[TD="class: xl66"]1[/TD]
[TD="class: xl66"] a[/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[/TR]
[TR]
[TD="class: xl66"]2[/TD]
[TD="class: xl66"] c[/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[/TR]
[TR]
[TD="class: xl66"]3[/TD]
[TD="class: xl66"] b[/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[/TR]
[TR]
[TD="class: xl66"]4[/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[/TR]
[TR]
[TD="class: xl66"]5[/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[/TR]
</tbody>[/TABLE]
join(", ",A1:A3) will return a, c, b
but when i add a condition to the range, like <>a , it wont work anymore
the result expected is c, b
I know it like the arguments used in Max WorksheetFunction.Max method but can't find the information for it to work:
"Arguments can either be numbers or names, arrays, or references that contain numbers."
p/s please pardon my English skill.
But now i need to use other formula to form the range inside it, it doesn't work anymore.
please see sample below
[TABLE="width: 256"]
<tbody>[TR]
[TD="class: xl66, width: 64"][/TD]
[TD="class: xl66, width: 64"]A[/TD]
[TD="class: xl66, width: 64"]B[/TD]
[TD="class: xl66, width: 64"]C[/TD]
[/TR]
[TR]
[TD="class: xl66"]1[/TD]
[TD="class: xl66"] a[/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[/TR]
[TR]
[TD="class: xl66"]2[/TD]
[TD="class: xl66"] c[/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[/TR]
[TR]
[TD="class: xl66"]3[/TD]
[TD="class: xl66"] b[/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[/TR]
[TR]
[TD="class: xl66"]4[/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[/TR]
[TR]
[TD="class: xl66"]5[/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[/TR]
</tbody>[/TABLE]
join(", ",A1:A3) will return a, c, b
but when i add a condition to the range, like <>a , it wont work anymore
the result expected is c, b
I know it like the arguments used in Max WorksheetFunction.Max method but can't find the information for it to work:
"Arguments can either be numbers or names, arrays, or references that contain numbers."
Code:
Public Function join(d As String, ParamArray r() As Variant) As String
Dim s As String, c As Range
Dim elem As Range
Dim i As Long
For i = LBound(r) To UBound(r)
For Each elem In r(i)
For Each c In elem
If CBool(Len(c.Text)) Then _
s = s & IIf(Len(s), d, vbNullString) & c.Value
Next c
Next elem
Next i
join = s
End Function
p/s please pardon my English skill.