I'd do what Haxslash is doing, however only for a small footprint of 3x3. I think you'll probably have a bigger grid to worry about - so I'd do something like this - lets assume a 16x16 grid and 5 different colours numbered 0 to 4
fail=1
For c=0 to 4
For y=0 to 15
count=0
For x=0 to 15
If cell(x,y)=c then inc count,1 else count=0
If count=3 then fail=0
Next x
Next y
Next c
So that would scan the cell array for C - if the cell colour is C, then that's a match - and increment the count, otherwise reset the count. If the count adds up to 3, and you want to remove rows of 4 5 etc, then perhaps just set the count to 2, so if the next colour is the same again, the count is back at 3, removing the cell or whatever, kinda nibbling at the grid if you know what I mean....
If count=3 then fail=0 : count=2
Thats only for left to right though, if you want to scan up and down to, duplicate that and switch around the For Next loops - so Y increments in the shortest loop instead of X...
For c=0 to 4
For x=0 to 15
count=0
For y=0 to 15
If cell(x,y)=c then inc count,1 else count=0
If count=3 then fail=0
Next y
Next x
Next c
To clear the cells for instance, I'd take the current position in the scan, and clear the current cell and the 2 cells to the left. That way, it might be clearing cells that are already clear - but it would be pretty robust and straightforward. Once you have removed cells, then have then tumble down, by checking the cell above for colour. If there are no matches, then the variable fail will be 1, otherwise a match will set that to 0. I'd repeat until there are no matches, that way you have chain reactions as the board settles - chain reactions are always good, add in score multipliers and sounds and stuff to chain reactions - it encourages thoughtful play.
This is how I would do a Bejewelled game, if that's the sort of thing you have in mind.