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

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hello & welcome
What exactly is not working?
This looks to do what your asking for.
 
Upvote 0

Forum statistics

Threads
1,213,565
Messages
6,114,338
Members
448,570
Latest member
rik81h

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
Back
Top