user20159
user20159

Reputation: 175

Inserting text beteween cells Excel VBA

I have a lot of cells separated by 3 rows each, and in those 3 rows I have to insert some words. Say, Distance, Centroid and Wind Velocity. Does any one know how to do that in Excel VBA? I attach a picture to explain it better.

Thanks in advance!

enter image description here

Upvotes: 1

Views: 490

Answers (1)

Santosh
Santosh

Reputation: 12353

Try below code

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

Upvotes: 1

Related Questions