ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro to copy cells (https://www.excelbanter.com/excel-discussion-misc-queries/39855-macro-copy-cells.html)

Esrei

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



Norman Jones

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





Esrei

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







All times are GMT +1. The time now is 04:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com