It is far too complicated to recreate such a scenario. And if it does not match yours, then our solution will not work for you.
For this kind of requests, please create a sample file with the layout of your original file, filled with sample data and colored cells with the expected result.
At best make a copy of your original file and anonymize the necessary data. For this please download this file
https://www.dropbox.com/s/rkfxuh85j5wyj9y/modAnonymize.bas?dl=1
Open your Excel file
Right-click on the sheet tab
Choose "View Code"
Press CTRL-M
Select the downloaded file and import
Close the VBA editor
Select the cells with the confidential data
Press Alt-F8
Choose the macro Anonymize
Click Run
Upload it on OneDrive (or an other Online File Hoster of your choice) and post the download link here.
Then we can look at the file and try to find a solution. Thank you for your understanding.
Andreas.