Help with Copy Paste Loop

BZEWomanInTx

New Member
Joined
Oct 24, 2015
Messages
17
Hi, I need help with a code that will look in Column E and after every date change insert 3 blank rows, copy B1:L3 and paste in the the newly inserted blank rows starting in Column B, then replace the first SPL after !ENDTRNS with TRNS. Repeat until the end of the data. I'm attaching a screenshot of what it needs to look like after the macro is done. Thanks in advance for your kind assisntance.

Project A.xlsm
ABCDEFGHIJKL
1!TRNSTRNSIDTRNSTYPEDATEACCNTNAMECLASSAMOUNTDOCNUMMEMOCLEAR
2!SPLSPLIDTRNSTYPEDATEACCNTNAMECLASSAMOUNTDOCNUMMEMOCLEAR
3!ENDTRNS
48089SPL1/2/2020
58587SPL1/2/2020
68105SPL1/2/2020
78603SPL1/2/2020
88210SPL1/3/2020
98708SPL1/3/2020
108400SPL1/13/2020
118898SPL1/13/2020
128406SPL1/13/2020
138904SPL1/13/2020
148420SPL1/13/2020
158918SPL1/13/2020
168434SPL1/13/2020
178932SPL1/13/2020
188448SPL1/13/2020
198946SPL1/13/2020
208134SPL1/15/2020
218632SPL1/15/2020
228149SPL1/15/2020
238647SPL1/15/2020
248164SPL1/15/2020
258662SPL1/15/2020
268179SPL1/15/2020
278677SPL1/15/2020
288191SPL1/15/2020
298689SPL1/15/2020
308324SPL1/15/2020
318822SPL1/15/2020
328001SPL1/16/2020
338499SPL1/16/2020
348002SPL1/16/2020
358500SPL1/16/2020
368003SPL1/16/2020
378501SPL1/16/2020
388004SPL1/16/2020
398502SPL1/16/2020
Sheet1
 

Attachments

  • End Result.jpg
    End Result.jpg
    171.8 KB · Views: 5

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
How about
VBA Code:
Sub BZEWomanInTx()
   Dim i As Long
   Dim Ary As Variant
   
   Ary = Range("B1:L3").Value2
   For i = Range("E" & Rows.Count).End(xlUp).Row To 5 Step -1
      If Cells(i, 5) <> Cells(i - 1, 5) Then
         Rows(i).Resize(3).Insert
         Cells(i, 2).Resize(3, 11).Value = Ary
         Cells(i + 3, 2) = "TRNS"
      End If
   Next i
End Sub
 
Upvote 0
Solution
How about
VBA Code:
Sub BZEWomanInTx()
   Dim i As Long
   Dim Ary As Variant
  
   Ary = Range("B1:L3").Value2
   For i = Range("E" & Rows.Count).End(xlUp).Row To 5 Step -1
      If Cells(i, 5) <> Cells(i - 1, 5) Then
         Rows(i).Resize(3).Insert
         Cells(i, 2).Resize(3, 11).Value = Ary
         Cells(i + 3, 2) = "TRNS"
      End If
   Next i
End Sub
OMG!!!! You are awesome!!! Thank you, thank you.
 
Upvote 0

Forum statistics

Threads
1,215,420
Messages
6,124,803
Members
449,190
Latest member
cindykay

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