Go to
gummy-stuff.org
Its a very comprehensive site with all sorts of excel financial models (monte carlos, etc) all to download for free. The VBA code is in each of the files, and viewable for free. Its from a math professor who occasionally posts on diehards. You can see how the data is pulled from Yahoo Finance by looking at the VBA code too.