Allow formulas to look vertically and horizontally

Allow a formula to look for values in a column, not just on the row. For example, I want to do a count if that counts all values in a column that match the cell in the current row.