The formation of an ionic compound from its corresponding elements is calculated by imagining a 3-step process:
An electron is removed from an atom in the gas phase to form a cation
Energy of this step: ionization energy of the corresponding element
An electron is added to another atom in the gas phase to form an anion
Energy of this step: electron affinity EA of the corresponding element
The ions in the gas phase come together to form an ionic bond
Energy of this step: Coulomb energy Ecoulomb