- Identify lot rows - I'm assuming your data starts in A2 with the “Security Name” column. Insert a helper column (say Z) called Type with this formula:
=IF(LEFT(A2,12)="Lot opened o","Lot","Rollup")
This marks each row as either "Lot" or "Rollup".
- Create a column for the Security Name (carried down)
In a new column (say AA, called SecurityNameNormalized), enter:
=IF(Z2="Rollup",A2,IF(Z2="Lot",LOOKUP(2,1/(Z$1:Z2="Rollup"),A$1:A2),""))
This looks up the most recent “Rollup” name above each lot, effectively carrying it down.
- Move the “Lot opened on…” text to a new column
If you want to separate the “Lot opened on:” part into its own column (say AB, LotDetail):
=IF(Z2="Lot",A2,"")
You can refine it to strip the “Lot opened on:” prefix:
=IF(Z2="Lot",TRIM(MID(A2,FIND(":",A2)+1,LEN(A2))),"")
- Delete roll-up rows that have associated lot rows:
- Filter the Type column for
"Rollup". - Keep only those Rollup rows where no “Lot” follows before the next Rollup.
You can flag such rows automatically in another helper (say AC, KeepRollup):
=IF(Z2="Rollup",IF(COUNTIFS(Z3:INDEX(Z$2:Z$1000,MATCH(TRUE,INDEX((Z$3:Z$1000="Rollup"),0),0)+ROW(Z3)-ROW(Z$3)+1),"Lot")>0,"Delete","Keep"),"")
That formula looks ahead to see if a “Lot” exists before the next “Rollup” — if so, mark it for delete. Then just filter by “Keep” and delete the others.
- Final cleanup
Now you should have:
-
SecurityNameNormalizedshowing the correct security name for each lot -
LotDetailshowing the lot's open date - No unnecessary roll-up rows
You can delete the helper columns after confirming results.
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin