Sometimes it becomes difficult to concatenate many results in an array. For Example, we use
=Index( Table, Small( if( Array = Criteria, Row( Array ) ), Nth Small ), Column No.)
constructions, we often want all values in the resultant array to be in one cell delimited by "," or any other delimiter. But we are unable to do this, because there is no such concatenation function provided by the Microsoft. So I have come up with a UDF that will do the needful.
=Index( Table, Small( if( Array = Criteria, Row( Array ) ), Nth Small ), Column No.)
constructions, we often want all values in the resultant array to be in one cell delimited by "," or any other delimiter. But we are unable to do this, because there is no such concatenation function provided by the Microsoft. So I have come up with a UDF that will do the needful.
Here is the syntax.
=JoinR( Range_OR_Array, Delimiter As String )
=JoinC( Range_OR_Array, Delimiter As String )
JoinR:-
JoinC:-
Note:- Code has been revised for more efficiency.
You can see some application in the Post #8 of the following link:-
http://www.excelforum.com/excel-programming-vba-macros/1064234-multi-dimensional-concatif-coding.html
JoinR:-
Function JoinR(ByRef x As Variant, ByRef Delim As String) As String
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Developed by Vikas Gautam '
' Forum Expert at ExcelForum.Com '
'For Concatenating Arrays or Ranges having One Column and Many rows '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dLen = Len(Delim)
With Application
SourceArray = .Transpose(x)
Delim2 = Delim & Delim
Temp = Replace(Join(SourceArray, Delim), Delim2, "")
Do While InStr(1, Temp, Delim2, 1) > 0
Temp = Replace(Temp, Delim2, "")
Loop
End With
If Left(Temp, dLen) = Delim Then Temp = Mid(Temp, dLen + 1, Len(Temp))
If Right(Temp, dLen) = Delim Then Temp = Left(Temp, Len(Temp) - dLen)
JoinR = Temp
End Function
JoinC:-
Function JoinC(ByRef x As Variant, ByRef Delim As String) As String
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Developed by Vikas Gautam '
' Forum Expert at ExcelForum.Com '
'For Concatenating Arrays or Ranges having One Row and Many Columns '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dLen = Len(Delim)
With Application
SourceArray = .Transpose(.Transpose(x))
Delim2 = Delim & Delim
Temp = Replace(Join(SourceArray, Delim), Delim2, "")
Do While InStr(1, Temp, Delim2, 1) > 0
Temp = Replace(Temp, Delim2, "")
Loop
End With
If Left(Temp, dLen) = Delim Then Temp = Mid(Temp, dLen + 1, Len(Temp))
If Right(Temp, dLen) = Delim Then Temp = Left(Temp, Len(Temp) - dLen)
JoinC = Temp
End Function
Note:- Code has been revised for more efficiency.
You can see some application in the Post #8 of the following link:-
http://www.excelforum.com/excel-programming-vba-macros/1064234-multi-dimensional-concatif-coding.html
Enjoy the codes, Good Luck.!
Attached is the example workbook.
kırşehir
ReplyDeletekarabük
adıyaman
niğde
ordu
5HW