I have a block of data like below that I need to insert into a sheet with several thousand rows.
The first catch is that some of the block is already there but incomplete. This is best illustrated with examples.
In this case, I am missing rows for 7010 and 7020.
In this case, I am only missing 7010. It’s all random. I could override the existing block but the second catch is that I have data in the cells to the right so the obvious solution is to insert blank rows corresponding to the missing numbers.
Because I know the block always start with a 7, I started doing something like (the data is in column B)
If Left(Cells(Row, 2), 1) = 7 Then
If Cells(Row, 2) = 7005 Then
Then realized that’s a quagmire of nested if statements. And then it gets trickier because after I insert the necessary row, the cycle repeats XD so I thought maybe I use an array to store the incomplete block and compare it to the complete block then insert rows that way but that’s also a nightmare. This is all made worse because I have to loop through the entire sheet and do this wherever necessary. I can code so if anyone can just provide logic, that will suffice.
If it’s easier, I do not need to fill in the newly inserted rows. Meaning I can just leave it all blank like below. Let me know if this makes sense or need more info.




1Loop through the first block and check if it is there or not in the 2nd block.2If it is not then simply add it to the end of the block3Sort the 2nd complete block based on column 1 in the end. The blank rows on the right of the numbers will be automatically created :)