You have a clear problem, and your instinct to solve it with conditional formatting is smart. But the tool itself is fighting you. You built a working border rule for single-column data, and now you are hitting the wall that every spreadsheet user eventually hits: the tool works well for simple patterns, but it was never designed for the way you actually think about data.
The user who posted this question is trying to group payments into double boxes based on a code column. They managed to get borders working for a single column, but the double-column layout broke the logic. This is not a failure of skill. It is a failure of the tool. Conditional formatting rules in traditional spreadsheets evaluate cell by cell, not group by group. You can write a formula that says "add a border to this cell if the value above is different," but that logic does not scale when you need the border to span two columns and wrap around a set of rows that share a code. You end up stacking rules, writing nested formulas, and still getting gaps or missing borders. The frustration is earned.
What this reveals is a deeper limitation. You are not trying to highlight cells. You are trying to communicate structure. The borders are not decoration; they are a visual grammar that tells the reader "these four payments belong together, and this one over there belongs to a different group." That is a semantic need, not a formatting one. Traditional spreadsheets treat data as a flat grid of independent cells. They do not understand groups, hierarchies, or relationships unless you build them by hand with formulas and manual formatting. Every time you add a new payment, you have to check whether the borders still line up. That is maintenance, not productivity.
The alternative is a tool that understands groups natively. Imagine a spreadsheet where you can define a payment group by its code, and the borders, shading, and spacing adjust automatically as you add or remove rows. No conditional formatting formulas. No manual checks. The structure updates itself because the tool knows that the code column defines the grouping logic. That is not a distant future. It is what AI-native spreadsheets do today. They let you work with your data the way you think about it, not the way the grid forces you to.
Stop fighting conditional formatting for what it was never meant to do. If your workflow requires grouping payments into bordered boxes, and you are spending more time debugging rules than analyzing the payments themselves, the problem is not your formula. It is the tool. Explore a spreadsheet that treats groups as a first-class concept. Your time is better spent on the payments, not the borders.