在包含连接值的表末尾插入新列

问题描述

我有一个工作表,我想设计一个宏以在表的末尾插入一列,以包含表中三列的连接值,并在它们之间使用分隔符(“-”)。到目前为止,我已经能够插入新列,但无法连接值。我的代码如下,并添加了注释....

Sub Demo()
Dim tbl As ListObject
Dim cel As Range
Dim i As Long
Dim delim As String
    Set tbl = ActiveSheet.ListObjects("Table1")
    delim = "-"
    With tbl
        .ListColumns.Add.Name = "CMRD"
        For Each cel In .ListColumns("CMRD").DataBodyRange.Cells
            With .DataBodyRange
                i = cel.Row - 1
                cel.Value = .Cells(i,6) & delim & .Cells(i,2) & delim & .Cells(i,13)
            End With
        Next
    End With
End Sub

任何帮助将不胜感激。谢谢

编辑:解决方案已验证-代码已更新,可以反映出来。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)