View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Luke M[_4_] Luke M[_4_] is offline
external usenet poster
 
Posts: 457
Default Script to insert Row

Sub CopyInsert()
'Find the last cell in column A
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
For i = LastRow To 1 Step -1
If Cells(i, 1).Value = "NS" Or Cells(i, 1).Value = "MT" Then
'Copy row
Cells(i, 1).EntireRow.Copy
'Insert new row
Cells(i + 1, 1).Insert Shift:=xlDown
'Clear the inserted row's A cell
Cells(i + 1, 1).ClearContents
End If
Next

End Sub

--
Best Regards,

Luke M
"Jeremy" wrote in message
...
How would I write a scrtip to insert a row under the number in A that
holds a
"NS" or "MT"? I would also like it to copy the row that has "NS" or "MT"
in
it and paste it in the row that was inserted underneith. When it copies
the
row it will copy the whole row except what is in A.

Example Before
A B
1 MT 12
2 D 14
3 x 15


Example After
1 2
1 MT 12
2 12
3 D 14
4 X 15


Thanks