Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Macro to copy cells
I have this macro that inserts 26 rows when the value in B changes. (Works
wonderfull) Now I want the macro to after 26 rows were inserted copy Range B2:K25 to the 2nd row in the range that were inserted. in other words find a value in B move 2 cells down and past B:K Hope I make sence. I am inserting a header for invoice lines. Sub Deilv() Dim LastRow As Long Dim row_index As Long Application.ScreenUpdating = False LastRow = ActiveSheet.Cells(Rows.Count, "b").End(xlUp).Row For row_index = LastRow - 1 To 26 Step -1 If Cells(row_index, "B").Value < _ Cells(row_index + 1, "B").Value Then Cells(row_index + 1, "B").Resize(26).EntireRow. _ insert Shift:=xlDown End If Next Application.ScreenUpdating = True End Sub |
#2
|
|||
|
|||
Hi Esrei,
See response in your original thread. --- Regards, Norman "Esrei" wrote in message ... I have this macro that inserts 26 rows when the value in B changes. (Works wonderfull) Now I want the macro to after 26 rows were inserted copy Range B2:K25 to the 2nd row in the range that were inserted. in other words find a value in B move 2 cells down and past B:K Hope I make sence. I am inserting a header for invoice lines. Sub Deilv() Dim LastRow As Long Dim row_index As Long Application.ScreenUpdating = False LastRow = ActiveSheet.Cells(Rows.Count, "b").End(xlUp).Row For row_index = LastRow - 1 To 26 Step -1 If Cells(row_index, "B").Value < _ Cells(row_index + 1, "B").Value Then Cells(row_index + 1, "B").Resize(26).EntireRow. _ insert Shift:=xlDown End If Next Application.ScreenUpdating = True End Sub |
#3
|
|||
|
|||
Thanks
"Norman Jones" wrote: Hi Esrei, See response in your original thread. --- Regards, Norman "Esrei" wrote in message ... I have this macro that inserts 26 rows when the value in B changes. (Works wonderfull) Now I want the macro to after 26 rows were inserted copy Range B2:K25 to the 2nd row in the range that were inserted. in other words find a value in B move 2 cells down and past B:K Hope I make sence. I am inserting a header for invoice lines. Sub Deilv() Dim LastRow As Long Dim row_index As Long Application.ScreenUpdating = False LastRow = ActiveSheet.Cells(Rows.Count, "b").End(xlUp).Row For row_index = LastRow - 1 To 26 Step -1 If Cells(row_index, "B").Value < _ Cells(row_index + 1, "B").Value Then Cells(row_index + 1, "B").Resize(26).EntireRow. _ insert Shift:=xlDown End If Next Application.ScreenUpdating = True End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Correctly copy cells with a macro | Excel Discussion (Misc queries) | |||
How to copy subtotalled cells to a new worksheet (in a macro), wi. | Excel Discussion (Misc queries) | |||
Macro Help: Concatenate Populated Cells in Column A | Excel Discussion (Misc queries) | |||
Macro to copy value in empty cells | Excel Discussion (Misc queries) | |||
Copy down - special to fill only the blank cells | Excel Discussion (Misc queries) |