Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Macro that inserts lines
I have this macro that inserts a line if the value in D changes and copy the
value in D to A. I want this macro to only start looking in D14 or from row 14. tx for all the help Dim row_index As Long Application.ScreenUpdating = False lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row For row_index = lastrow - 1 To 2 Step -1 If Cells(row_index, "D").Value < _ Cells(row_index + 1, "D").Value Then Cells(row_index + 1, "D").EntireRow.Insert _ (xlShiftDown) Cells(row_index + 1, 1).Value = Cells(row_index + 2, 4).Value End If Next End Sub |
#2
|
|||
|
|||
Is it not working then? If so, how?
-- HTH Bob Phillips "Esrei" wrote in message ... I have this macro that inserts a line if the value in D changes and copy the value in D to A. I want this macro to only start looking in D14 or from row 14. tx for all the help Dim row_index As Long Application.ScreenUpdating = False lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row For row_index = lastrow - 1 To 2 Step -1 If Cells(row_index, "D").Value < _ Cells(row_index + 1, "D").Value Then Cells(row_index + 1, "D").EntireRow.Insert _ (xlShiftDown) Cells(row_index + 1, 1).Value = Cells(row_index + 2, 4).Value End If Next End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro won't run macro | Excel Discussion (Misc queries) | |||
soft-coding lines in a macro | Excel Discussion (Misc queries) | |||
Playing a macro from another workbook | Excel Discussion (Misc queries) | |||
Date macro | Excel Discussion (Misc queries) | |||
Macro and If Statement | Excel Discussion (Misc queries) |