Pick values from multiple cells and paste output i

2019-03-06 06:03发布

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.

2条回答
ら.Afraid
2楼-- · 2019-03-06 06:52

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
查看更多
别忘想泡老子
3楼-- · 2019-03-06 07:08

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)))

enter image description here


¹ 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.

查看更多
登录 后发表回答