Herschel and Planck are surveying the sky at unprecedented angular scales and sensitivities over large areas. But both experiments are limited by source confusion in the submillimeter. The high confusion noise in particular restricts the study of the clustering properties of the sources that dominate the cosmic infrared background. At these wavelengths, it is more appropriate to consider the statistics of the unresolved component. In particular, high clustering will contribute in excess of Poisson noise in the power spectra of CIB anisotropies. These power spectra contain contributions from sources at all redshift. We show how the stacking technique can be used to separate the different redshift contributions to the power spectra. We use simulations of CIB representative of realistic Spitzer, Herschel, Planck, and SCUBA-2 observations. We stack the 24um sources in longer wavelengths maps to measure mean colors per redshift and flux bins. The information retrieved on the mean spectral energy distribution obtained with the stacking technique is then used to clean the maps, in particular to remove the contribution of low-redshift undetected sources to the anisotropies. Using the stacking, we measure the mean flux of populations 4 to 6 times fainter than the total noise at 350um at redshifts z=1 and z=2, respectively, and as faint as 6 to 10 times fainter than the total noise at 850um at the same redshifts. In the deep Spitzer fields, the detected 24um sources up to z~2 contribute significantly to the submillimeter anisotropies. We show that the method provides excellent (using COSMOS 24um data) to good (using SWIRE 24um data) removal of the z<2 (COSMOS) and z<1 (SWIRE) anisotropies. Using this cleaning method, we then hope to have a set of large maps dominated by high redshift galaxies for galaxy evolution study (e.g., clustering, luminosity density).