Insert Copied Cells Based On The Value Changing In Column A

TkdKidSnake

Active Member
Joined
Nov 27, 2012
Messages
255
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I am trying to insert copied cells into another spreadsheet based on the value changing in column A, if it changes the rows are inserted underneath the 1st value and before the 2nd value. What I have currently is the below however I am seeing some anomalies.

The codes is activitate whilst in the correct worksheet
Code:
Dim bRow As Long
    For bRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row To 3 Step -1
        If Cells(bRow, "A") <> Cells(bRow - 1, "A") Then
       
            Rows(bRow).Resize(5).EntireRow.Insert
            Windows("OTIF Dashboard.xlsm").Activate
            Sheets("OTIF Detail").Rows("5:11").Copy
            Windows("RawData.csv").Activate
            Range("A" & bRow).PasteSpecial (xlPasteAll)

If anyone can see where I have gone wrong it would be greatly appreciated, also the data starts at A3 and currently this stating from the very 1st cell and inserting immediately

Thanks in advance
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
What are the "anomalies" you speak of?
Also you are inserting 5 new rows, but pasting 7 rows.
 
Upvote 0
Thank you Fluff I had completely missed that, the only anomaly I have now is that its inserting the 7 lines straight after the 1st two rows which I dont want and I am not sure what to change.

What are the "anomalies" you speak of?
Also you are inserting 5 new rows, but pasting 7 rows.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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