We study exchange coupling due to the interelectron Coulomb interaction between two ferromagnetic grains embedded into an insulating matrix. This contribution to the exchange interaction complements the contribution due to virtual electron hopping between the grains. We show that the Coulomb and the hopping-based exchange interactions are comparable. However, for most system parameters these contributions have opposite signs and compete with each other. In contrast to the hopping-based exchange interaction the Coulomb-based exchange is inversely proportional to the dielectric constant of the insulating matrix ɛ . The total intergrain exchange interaction has a complicated dependence on the dielectric permittivity of the insulating matrix. Increasing ɛ one can observe the ferromagnet-antiferromagnet (FM-AFM) and AFM-FM transitions. For certain parameters no transition is possible, however even in this case the exchange interaction has large variations, changing its value three times by increasing the matrix dielectric constant.