Good day to you all.
As the title implies, I would like to copy entire row and paste it at the SAME WORKSHEET below the cell that contain specific word. For example,
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]XXXXXX[/TD]
[TD]ABCDEFG/123456[/TD]
[TD]YYYYY[/TD]
[/TR]
</tbody>[/TABLE]
I would like to change the above table to :
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]XXXXXX[/TD]
[TD]ABCDEFG/123456[/TD]
[TD]YYYYY[/TD]
[/TR]
[TR]
[TD]XXXXXX[/TD]
[TD]ABCDEFG/123456[/TD]
[TD]YYYYY[/TD]
[/TR]
</tbody>[/TABLE]
The specific text i meant was this symbol "/". So if column B contains 2 "/", then 2 additional row will be added below the original row.
I have a macro that could possibly do this but end up giving me an error. I would really appreciate if someone could point out where is the error.
Thank you!
As the title implies, I would like to copy entire row and paste it at the SAME WORKSHEET below the cell that contain specific word. For example,
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]XXXXXX[/TD]
[TD]ABCDEFG/123456[/TD]
[TD]YYYYY[/TD]
[/TR]
</tbody>[/TABLE]
I would like to change the above table to :
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]XXXXXX[/TD]
[TD]ABCDEFG/123456[/TD]
[TD]YYYYY[/TD]
[/TR]
[TR]
[TD]XXXXXX[/TD]
[TD]ABCDEFG/123456[/TD]
[TD]YYYYY[/TD]
[/TR]
</tbody>[/TABLE]
The specific text i meant was this symbol "/". So if column B contains 2 "/", then 2 additional row will be added below the original row.
I have a macro that could possibly do this but end up giving me an error. I would really appreciate if someone could point out where is the error.
Code:
Sub Insert_CopyPaste()
Dim LastRow As Long, I As Long, txt As String
txt = "/" 'set text to search
With Sheets("Sheet9")
LastRow = .Range("B6000").End(xlUp).Row
Do While I <= LastRow
If .Range("C" & I).Value = "/" Then
.Range("a" & I).EntireRow.Copy
.Range("a" & I + 1).EntireRow.Insert
.Range("a" & I + 1).PasteSpecial xlPasteValues
End If
I = I + 1 'goto next row to check
Loop
End With
End Sub
Thank you!