使用VBA跨列复制文本

我有一个Excel工作簿中包含一个“输出示例”和另一列包含一个定义的列。 我需要输出示例在定义中。 于是我写了一个macros,在文本的末尾加上“Ex:”这个短语,然后复制相邻列中的文本并粘贴到“Ex:”之后

Sub Exampletransfer() ' ' Exampletransfer Macro ' ' Keyboard Shortcut: Ctrl+Shift+E ' Range("H2").Select ActiveCell.FormulaR1C1 = _ "The age range, in years of a customer. Ex: " Range("I2").Select ActiveCell.FormulaR1C1 = "1-4" Range("H2").Select ActiveCell.FormulaR1C1 = _ "The age range, in years of a customer. Ex: 1-4" Range("H3").Select End Sub 

我附上了一张照片。 我需要这个发生在整个专栏。 我想我不明白如何让一个macros继续沿着一列。

我有 什么我需要的

干得好。 确保在Range和Cells方法中更改数据开始的位置!

 Sub AppendData() Dim myRange As range Dim myCell As range 'Change where you data starts. My practice started in B4, so that's 'what I used. Set myRange = range("B4", Cells(Rows.count, "B").End(xlUp)) For Each myCell In myRange If myCell.Value <> "" Then myCell.Value = myCell.Value & " Ex: " & myCell.Offset(0, 1).Value End If Next myCell End Sub