将多个细胞的含量组合成1个细胞

时间:2014-03-03 16:48:30

标签: excel excel-formula

我有300个名字写在A1,B1,C1,D1等等...... 我希望它们在一个单元格中,每个名称用逗号分隔。

我已经尝试了很多自动化连接函数&,但是徒劳无功。拖动单元格这样的东西是行不通的。

有任何提示吗?谢谢

2 个答案:

答案 0 :(得分:1)

试试这个微小的宏:

Sub KonKat()
    stt = Cells(1, 1).Value
    For i = 2 To 300
        stt = stt & ", " & Cells(1, i).Value
    Next i
    Cells(2, 1).Value = stt
End Sub

结果将放在单元格 A2

答案 1 :(得分:0)

使用VB得到答案....谢谢:)

Sub MergeOneCell()
'Updateby20140128
Dim Rng As Range
Dim WorkRng As Range
Dim Sigh As String
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Sigh = Application.InputBox("Symbol merge", xTitleId, ",", Type:=2)
xOut = ""
Application.DisplayAlerts = False
For Each Rng In WorkRng
xOut = xOut & Rng.Value & Sigh
Next
With WorkRng
.Merge
.Value = VBA.Left(xOut, VBA.Len(xOut) - 1)
End With
Application.DisplayAlerts = True
End Sub