trying this code am i missing something I can't get it to work?

Occasional Visitor

Function transposeRange(Rg As Range)
'Created to put all dynamic values in one column inside one row in one cell
Dim xCell As Range
Dim xStr As Range
For Each xCell In Rg
If Not IsEmpty(xCell.Value) Then
xStr = xStr & xCell.Value & ","
End If
transposeRange = Left(xStr, Len(xStr) - 1)
End Function

2 Replies

@RoweeYadin Not sure what you want to achieve, but by the name of the function you want to transpose a range, Are you aware that there is a function called TRANSPOSE? Depending on your Excel version you may have to enter it with Ctrl-Shift-Enter, rather than jus Enter.

You need to declare xStr as string, not range. But, if you have office 2016 or higher, you should check if you have the built-in textjoin function, which I believe will do what you need.