function sameValueExists(yy) { for (y = yy - 1; y >= 2; y--) { if ([2,y] == [2,yy] && [3,y] == [3,yy]) { return true; } } return false; } currentDate = [1,Bottom]; for (y = Bottom; y >= 2; y--) { if ([1,y] != currentDate || sameValueExists(y)) { DeleteRow(y); } }