def find_shift(p, row, test_col):
    """Find how many cells to shift up when encountering possible merged cells."""
    max_shift = 4
    for shift in range(max_shift):
        test_val = p[test_col + str(row - shift)].value

        # If None,the cells were merged vertically; look up.
        if test_val is not None:
            return shift
        shift += 1
    raise AttributeError("Problem parsing merged cell.")