In Google Sheets there is now the Alternating rows formatting. It's almost the equivalent of of tables in Excel.BackgroundWhat if I have a sheet that is sorted by Invoice #'s, my unique number associated with a bill I send out to someone, but that someone breaks my invoices up into multiple line items associated with their own number called a Purchase-Order-Number.QuestionHow do I Highlight every other invoice such that I can more easily distinguish which Purchase-Orders belong to which Invoices?
Google Sheets Alternate Row Color by Unique Sorted Values
google spreadsheets;conditional formatting
ScenarioIf you have 500 items, in column B, but only 20 of them are unique invoices due to them being broken up into purchase orders. It makes sense to keep them separate so you can more easily reconcile checks that are written to you.SolutionThe solution I came up with involves using the custom-formula for conditional formatting.If column A is the Purchase-Order Numbers ( that are entirely unique ) and column B are your invoices that repeat multiple times. Assuming you have headers in row 1.=ISODD(MATCH($B2,UNIQUE($B$2:$B)))Explanation of SolutionUNIQUE() is an array returning formula that is exclusive to google sheets (it does not work in excel). This allows you to figure out how many unique invoices exist within column B. So UNIQUE($B$2:$B) returns a list of only the unique numbers, removing all duplicates.MATCH() returns an integer of where an item is located in a 1 dimensional range or array. I used it to look at each item in column B and find it's location within the array created by UNIQUE($B$2:$B) ; SO MATCH($B2,UNIQUE($B$2:$B)) will look at cell B2, and find where it is located in UNIQUE($B$2:$B) and return a number that represents which place it is in the list.=ISODD() returns TRUE or FALSE depending on the number you give it. For Instance ISODD(1) will return TRUE. So if we wrap ISODD() around our match-unique formula it will alternate with TRUE, FALSE per each different invoice. SO, =ISODD(MATCH($B2,UNIQUE($B$2:$B)))