We analyzed the long-term evolution of two active regions (ARs), NOAA 7978 and 8100, from their emergence through their decay using observations from several instruments on board SoHO (MDI, EIT and LASCO) and Yohkoh/SXT. We computed the evolution of the relative coronal magnetic helicity from one central meridian passage to the next, combining data from MDI and SXT with linear force-free models of the coronal magnetic field. Next, we calculated the injection of helicity by photospheric differential rotation using MDI magnetic maps and a mean differential rotation profile. To estimate the depletion of magnetic helicity we counted all the CMEs of which these ARs were the source, and we evaluated their helicity assuming a one to one correspondence with magnetic clouds (MCs) with an average helicity content; this value was computed for a sample of 18 clouds using a cylindrical linear force-free model. Out of our three helicity estimates (variation of coronal magnetic helicity, injection by differential rotation and ejection via CMEs) the one with the largest uncertainty is the amount of helicity ejected via CMEs. However, we determined, by modeling a particular MC using three different approaches in cylindrical geometry (two force-free models and a non force-free model with constant current), that its magnetic helicity content was nearly independent of the model used to fit in situ field observations (Dasso et al. 2003, in preparation). This result justifies our use of the average magnetic helicity value considering only a single MC model. Comparing the three components in the helicity balance (see Table 1), we find that photospheric differential rotation is a minor contributor to the AR magnetic helicity budget. CMEs carry away at least 10 times more helicity than the one differential rotation can provide. Therefore, the magnetic helicity flux needed in the global balance should come from localized photospheric motions that, at least partially, reflect the emergence of twisted flux tubes. Taking into account the magnetic flux in the ARs and the number of turns that a uniformly twisted flux tube should have to survive its rise through the convection zone, we have found that the total helicity carried away in CMEs is approximately equal to the end-to-end helicity of the flux tubes that formed these two ARs. Therefore, we conclude that most of the helicity ejected in CMEs is generated below the photosphere and emerges with the magnetic flux. Extended versions of this work were published in Demoulin et al. (2002, Astronomy & Astrophys. 382, 650) and in Green et al. (2002, Solar Phys. 208, 43), while in Mandrini et al. (2003, Astrophys. & Space Sci., 290, 319) and van Driel-Gesztelyi et al. (2003, Adv. Space Res., 32, 1855) the helicity computations were revised to include the underestimation of magnetic flux density found in MDI data. After this revision, we confirmed our former results.