Shifting a cell based on a string value in a column

  • HI.,

    i am having a column (assume in B Column) with values of different string. I would like to find out string in the range ex: _formatversion = 1.0 and shift 3 rows down wherever the occurrences are found. i tried this below code. but unsuccessful.

    Could anyone help.


  • Try

    Code
    1. Sub Maybe()
    2. Dim i As Long
    3. For i = Cells(Rows.Count, 2).End(xlUp).Row To 2 Step -1
    4. If Cells(i, 2).Value = "_formatversion = 1.0" Then Cells(i, 2).Resize(3).Insert Shift:=xlDown '<---- _formatversion = 1.0 down also
    5. 'or
    6. ' If Cells(i, 2).Value = "_formatversion = 1.0" Then Cells(i, 2).Offset(1).Resize(3).Insert Shift:=xlDown '<---- _formatversion = 1.0 does not move
    7. Next i
    8. End Sub

    When deleting, inserting etc, always from the bottom up.