Edit: I don't have my spreadsheet with me, but I think I was assuming you had the cash flow to support the payment, and not reducing the investment amount.
We can run the calculation this way too.
I set up this sheet to calculate your net worth after the given term if you buy, if you lease, and if you do nothing but invest all your money. Then I defined the cost of each option as the difference between your net worth if you do nothing and your net worth if you buy or lease.
It seems however that your starting balance and monthly income have no impact at all on the results. The only thing that matters is the purchase price, lease price, and term (as well as, of course, your assumptions on depreciation and investment return).
The results of the calculation are the same except that in my first sheet I just noticed I was calculating interest after making the lease payment each month whereas on this one I'm calculating it before making the lease payment; also on the new sheet I'm comparing with the value of the investment at the end whereas on the first sheet I was comparing with the initial balance.
The second sheet's numbers for monthly cost are probably the more interesting ones, but I could make the first sheet behave the same way simply by computing the value of your investment if you do nothing and using that as the point of comparison. Tracking cash flow doesn't make any difference.
Obviously, if you keep the investment amount fixed whether you are making a lease payment or not, leasing comes out ahead. But that implies that if you bought, you wouldn't invest the money saved by not having a monthly payment... which seems like an odd assumption.
--------------------------------------------
I think the takeaway is this:
The cheapest possible lease seems to be about $180/month (this is based on a local advertisement for a Hyundai Accent, a very cheap car).
Once you know the baseline lease price, you can pick how long you want to keep a car and compute a sale price which will give you the same monthly cost as leasing over that term (hint: use Excel's goal seek function on this second sheet). So if you're going to keep a car for 36 months, you can buy a $13,396.52 car and pay the same amount monthly as the cheapest possible lease. (This doesn't consider insurance and maintenance.) But the same Hyundai Accent is less that that, so if we're not consider insurance and maintenance, you get more car if you buy.
If we put a fixed monthly price on maintenance (say $50) and assume insurance will be equal if you lease or buy, then we can use the same goal seek function and get a reasonable purchase price that's equivalent to a given lease price.
So for the $180 lease...
36 months gives a purchase price of $10,000
48 months, $10,700
60 months, $11,400
72 months, $12,000
These are the prices that will cost you the same as leasing (including $50 month maintenance). If you buy a cheaper car than these prices (or spend less on maintenance), you will come out ahead if buy. If you buy a more expensive car (or spend more on maintenance), you will come out ahead if you lease.
In time, if anyone wants, I'll set up a sheet where you can enter the lease price, the maintenance cost assumption, and automatically calculate the equivalent purchase prices at various lengths of ownership.