I have a dataset which looks like:
A 0.998315185
B 0.232720507
C 0.010558964
D 0.004246209
E 0.002552556
I want to paste below output in one cell as:
0.998315185A+0.232720507B+0.010558964C+0.004246209D+0.002552556E
So that I can copy this and use it elsewhere.
You may try this User Defined Function. Use this function in a cell on the sheet like this...
=CombineData(A1:B5)
User Defined Function:
Function CombineData(ByVal Rng As Range) As String
Dim i As Long, j As Long
Dim str As String
Dim cell As Range
For i = 1 To Rng.Rows.Count
For j = Rng.Columns.Count To 1 Step -1
If str = "" Then
str = Rng.Cells(i, j)
Else
str = str & Rng.Cells(i, j)
End If
Next j
str = str & "+"
Next i
CombineData = str
End Function
Use the newer TEXTJOIN function as an array formula with CSE.
=TEXTJOIN("+", TRUE, B2:INDEX(B:B, MATCH(1E+99, B:B))&A2:INDEX(A:A, MATCH(1E+99, B:B)))
¹ The TEXTJOIN was introduced with Excel 2016 in the following versions:Excel for Android phones, Excel Mobile, Excel 2016 with Office 365, Excel 2016 for Mac, Excel Online, Excel for iPad, Excel for iPhone and Excel for Android tablet.