In order to explore whether Ru can be replaced by inexpensive Fe in dye molecules for solar cells, the differences in the electronic structure of Fe-and Ru-based dyes are investigated by X-ray absorption spectroscopy and first-principles calculations. Molecules with the metal in a sixfold, octahedral N cage, such as tris(bipyridines) and tris(phenanthrolines), exhibit a systematic downward shift of the N 1s-to-π * transition when Ru is replaced by Fe. This shift is explained by an extra transfer of negative charge from the metal to the N ligands in the case of Fe, which reduces the binding energy of the N 1s core level. The C 1s-to-π * transitions show the opposite trend, with an increase in the transition energy when replacing Ru by Fe. Molecules with the metal in a fourfold, planar N cage (porphyrins) exhibit a more complex behavior due to a subtle competition between the crystal field, axial ligands, and the 2+ vs. 3+ oxidation states.