In simple words you can't until you have all the historical data for each stock.
Also writing a Macro for excel will be too complicated.
As a financial engineer working for Hedge fund in NYC I can tell you its not a simple task. Rather than using excel you can use some website to this job for you. Some of these site are bloomberg, ***** finance advance tool, marketsimplified and macroaxis.