PDA

View Full Version : Iterating through Groupings using VBA



jdautel
05-05-2017, 10:40 AM
So I have a spreadsheet that looks like this:

19097

And goes on for a very very long time. I'm trying to write a simple script that will highlight in red for me each time a card made a purchase on the same date. It's not always sorted from newest to oldest in terms of the transaction date. So I need it to iterate through each sub group and If a date shows up more than once, it highlights both those rows red.

Any ideas?

Bob Phillips
05-05-2017, 10:49 AM
Use conditional formatting with a formula of

=COUNTIFS($A$1:$A$10,A2,$B$1:$B$10,B2)>1

just adjust to your ranges.

jdautel
05-05-2017, 11:18 AM
That would be a few hundred separate ranges to apply the conditional formatting to though.

Technically, the solution doesn't even have to be specific to the subgroups. More along the lines of if the value of two rows are identical in two columns, highlight them both red.

It's frustrating, I'd actually solved this problem once before but must of deleted it when cleaning out my personal macro workbook recently. And it's been a few months since I've touched vba so I can't remember the syntax to make this work.

Bob Phillips
05-05-2017, 03:59 PM
No, one range, it caters for the groups by checking columns A and B.

jdautel
05-08-2017, 07:36 AM
Wow. yeah it works like a charm. Thank you!