在单元格Excel VBA之间插入文本

时间:2013-10-31 20:20:09

标签: vba text insert

我有很多单元格,每行有3行,在这3行中我必须插入一些单词。说,距离,质心和风速。有没有人知道如何在Excel VBA中这样做?我附上一张图片来解释它。

提前致谢!

enter image description here

1 个答案:

答案 0 :(得分:1)

尝试以下代码

Sub InsertText()


    Dim lastRow As Long
    lastRow = Range("A" & Rows.Count).End(xlUp).Row

    For i = 2 To lastRow
        If Cells(i, 3) <> "" Then
            Cells(i + 1, 4) = "Distance"
            Cells(i + 2, 4) = "Centroid"
            Cells(i + 3, 4) = "Wind Velocity"
        End If
    Next

End Sub