trying to debug macro to copy and insert lines when cell is not empty

unaragazza

New Member
Joined
Sep 18, 2014
Messages
1
Hi, I'm trying to write a fairly simple macro and would appreciate any help debugging it.
The macro is intended to look at a row of text, and check and see if column E is empty. If it is empty, proceed to the next row and repeat. If it is not empty, the macro should insert a new line underneath, cut the data from columns E,F, and G in that row, and paste into column B in the newly created row beneath. Then it should copy the unique ID from column A above into the new row. It should then proceed to the next row and repeat through 50 rows. Here's what I have so far, but it's not working. Thanks!

Sub line_moving()
'
' line_moving Macro

ActiveCell.Offset(0, 4).Select
For i = 1 To 50

If Cells(i, 5) <> "" Then
ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
Selection.Insert Shift:=xlDown
ActiveCell.Offset(-1, 4).Range("A1:C1").Select
Selection.Cut
ActiveCell.Offset(1, -3).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(-1, -1).Range("A1").Select
Selection.Copy
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Else
ActiveCell.Offset(1, 0).Select
End If

Next i

End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
73,443
Office Version
  1. 365
Platform
  1. Windows
Hello & welcome
What exactly is not working?
This looks to do what your asking for.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,652
Messages
5,838,610
Members
430,557
Latest member
MK15

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top