C
cathal
I have an 800 x 7 matrix, how can I find similar cell contents, perhaps
showing similarites in different colours?
thanks, cathal...
showing similarites in different colours?
thanks, cathal...
cathal said:I have an 800 x 7 matrix, how can I find similar cell contents, perhaps
showing similarites in different colours?
......or you could try this bit of code, which took about 10
minutes to write and about the same amount of time to run.
One limitation is that it cycles through 39 colors, so if
you have more similarities than that, the colors will
be "recycled". You could always tweak that bit to allow
more colors though.
(.Interior.ColorIndex). Anothermore precise specs. You interpretted 'showing similarites in different colours'
as color coding entire cell background colors
interpretation would be matching the text colors of matching substrings (e.g.,
giving each substring that would be stored separately by L-Z compression a
separate color). Using the .Color property and the RGB function would have taken
a bit more time to implement, but it would handle thousands of colors if the OP
were using 16-bit pixel color depth. Also, working with Characters objects for
each cell in the range would also have added to the complexity.
Then there's the question of how text should match. If A1 contained 'One Two',
B1 contained 'Two Three', and C1 contained 'One Two Three', should C1 match A1
(which appears first in C1) or B1 (which is a longer match than A1) or both
somehow?
Also liked the O(N^2) algorithm. If you've already iterated through the first N
rows in the outer 'For Each a' loop, there's no reason to iterate through those
rows in the 'For Each b' loop.
If you simplify any problem sufficiently, it becomes simple to solve. Whether it
remains relevant is the big question.