Excel Blackjack with VBA Macro Code
As the most popular table game in any casino, Blackjack is a fairly straightforward game based on simple math - making it the perfect game to build inside of Excel.
If you know how to count cards, Blackjack is one of very few casino games that has a positive expected return - another one being some forms of video poker.
Of course, actually building the program wasn't simple at all. With so many small nuances to incorporate into the code, it took a lot of trial and error and many hours.
While not perfect, the program runs a game of Blackjack pretty well. It includes the ability to hit, stand, double, split, and surrender. One drawback is that the player cannot resplit cards - in other words, you can only split once per hand.
Unfortunately, there does seem to be a small bug in the code somewhere. On about 1 in 25 hands, an error will occur. I'm not sure what it is exactly, but I just included an error handler that resets the hand allowing you to play on.
When I originally posted Excel Blackjack on ExcelCasinoGames.com back around 2011, I hid the VBA code behind a password. Now the code is open to anyone who wants to learn and hopefully fix some of my bugs. There are a few hidden sheets that hide the guts of the program to make it run smoother. To see them, you'll need to run the "unhidesheet" macro.
If you want to test out different strategies, check out the Excel Blackjack Monte Carlo Simulator.
Excel Workbook with playable game and full access to the VBA macro code.