We investigate the delicate interplay between the types of singular fibers in elliptic fibrations of Calabi-Yau threefolds (used to formulate F-theory) and the matter representation of the associated Lie algebra. The main tool is the analysis and the appropriate interpretation of the anomaly formula for six-dimensional supersymmetric theories. We find that this anomaly formula is geometrically captured by a relation among codimension two cycles on the base of the elliptic fibration, and that this relation holds for elliptic fibrations of any dimension. We introduce a Tate cycle which efficiently describes this relationship, and which is remarkably easy to calculate explicitly from the Weierstrass equation of the fibration. We check the anomaly cancellation formula in a number of situations and show how this formula constrains the geometry (and in particular the Euler characteristic) of the Calabi-Yau threefold.