Tax Loss Harvesting: How It Works, With a Sheets Example
This content is for informational purposes only and isn't personalized financial, investment, tax, or legal advice. Consult a qualified professional before making financial decisions.
Tax loss harvesting means selling an investment that has dropped below what was paid for it, so the loss can reduce a tax bill, and then buying something similar to stay invested. It only applies to taxable brokerage accounts. This article covers the big picture, where the wash sale rule comes in, and a Google Sheets setup that flags lots sitting at a loss.
The limits, windows and definitions behind all of this are set by the IRS and can change. The key rules are summarized in a short table with their IRS sources, and the IRS pages have the full details.
What is tax loss harvesting and how does it work?
A loss only counts once the position is sold. Until then it is a paper loss and the tax code ignores it. The sequence looks like this:
- Sell a holding that is worth less than what was paid for it. The loss is now realized.
- The loss can offset capital gains from sales in the same year.
- If losses are larger than gains, the IRS allows a limited amount to offset other income, and the rest carries forward to later years.
- Buy a similar investment to stay in the market, but avoid triggering the wash sale rule (covered below).
The current loss limit and carryover rules are in IRS Topic 409, and IRS Publication 550 goes into more detail. Gains and losses are sorted into short-term and long-term based on how long the investment was held, and Topic 409 explains how the two kinds net against each other.
A simple example
The numbers are hypothetical. A year includes $6,000 of realized gains, and a different holding is sold at a $2,000 loss:
| Realized gains | $6,000 |
|---|---|
| Harvested loss | -$2,000 |
| Gains left to be taxed | $4,000 |
What that saves in tax depends on income, filing status and how long each position was held, so the tax figures are best taken from the IRS pages or a tax professional.
Tax loss harvesting rules at a glance
The IRS sets the rules, so each row below names where it comes from. Figures can change by tax year, and the linked pages have the current versions.
| Rule | What the IRS says | Source |
|---|---|---|
| Yearly loss limit | The deductible excess loss is the lesser of $3,000 ($1,500 if married filing separately) or the total net loss. | Topic 409 |
| Carryover | A net capital loss above that limit can be carried forward to later years. | Topic 409 |
| Long-term vs short-term | Generally, an asset held for more than one year before disposal gives a long-term gain or loss. | Topic 409 |
| Wash sale rule | A wash sale occurs when stock or securities are sold at a loss and, within 30 days before or after the sale, substantially identical stock or securities are bought (among other listed acquisitions). | Publication 550, Wash Sales |
The wash sale rule
The wash sale rule is the catch. It exists to stop someone from selling at a loss and buying the same thing right back just to claim the loss. Buying the same or a substantially identical investment close to the sale, either before or after it, can cause the loss to be disallowed for the time being.
The 30-day window and what counts as a purchase are defined in the Wash Sales section of IRS Publication 550.
A disallowed loss is generally not gone for good, since the publication explains how it gets added to the cost of the new shares. The details of that adjustment, and the exceptions, are in the same section.
Where it sneaks in
- Automatic recurring buys or dividend reinvestment in the same fund around the sale date.
- Purchases in other accounts, such as an IRA or a spouse's account. Publication 550 spells out which of these count.
For anyone with auto-invest on, the practical step is to pause the recurring buy of the sold fund around the sale, or point it at the replacement.
What counts as substantially identical
Publication 550 says the answer depends on the facts. Funds that track the same index are a gray area, and a tax professional is the right person to ask before relying on a swap.
Tax loss harvesting calculator: find harvestable lots in Google Sheets
A lot is one purchase of a security, with its own date and cost. Harvesting works lot by lot, and a holding that is up overall can still contain lots that are down. A sheet with one row per lot works as a simple calculator and makes those visible, using the GOOGLEFINANCE function for live prices.
The first four columns are typed in from the brokerage, and the last five are formulas. The figures below are made up for illustration:
| A Ticker | B Buy date | C Shares | D Cost basis | E Price | F Value | G Gain/loss | H Term | I Harvest |
|---|---|---|---|---|---|---|---|---|
| VXUS | 2026-02-14 | 40 | $2,800 | $62.00 | $2,480 | -$320 | Short | Candidate |
| VTI | 2025-04-02 | 15 | $3,900 | $330.00 | $4,950 | +$1,050 | Long | |
| BND | 2025-08-11 | 50 | $3,700 | $72.00 | $3,600 | -$100 | Long | Candidate |
Formulas for row 2, filled down for each lot:
E2: =GOOGLEFINANCE(A2, "price")
F2: =C2 * E2
G2: =F2 - D2
H2: =IF(TODAY() - B2 > 365, "Long", "Short")
I2: =IF(G2 < 0, "Candidate", "")
Two more cells give the short-term and long-term loss totals:
=SUMIFS(G:G, H:H, "Short", G:G, "<0")
=SUMIFS(G:G, H:H, "Long", G:G, "<0")
Caveats
- The term formula is an approximation. The IRS sets the actual holding period test (see Topic 409), so the brokerage's lot detail is the one to trust near the cutoff.
- Cost basis should come from the brokerage statement and not from memory, since reinvested dividends and past wash sales both change it.
- An extra column for the date the wash sale window ends, as defined in Publication 550, helps avoid buying back too early.
Anyone tracking holdings across accounts can adapt the same structure in the portfolio tracking script.
Is tax loss harvesting worth it?
It is not free money. Harvesting mostly defers tax instead of erasing it, because the replacement shares usually carry a lower cost basis.
The deferral can still have value, since the money keeps compounding in the meantime. A few situations push the math one way or the other:
| Helps more | Helps less |
|---|---|
| Large realized gains in the same year, such as selling a concentrated position or selling shares after RSUs vest | Little taxable gain or income for the loss to offset |
| A higher tax rate, where each dollar of offset is worth more | Small losses that do not cover the effort or trading costs |
| A sharp market drop, since it creates losses in otherwise healthy holdings | An account built mostly from recent contributions, where shares have had little time to drop |
State taxes can change the picture too. The Roth IRA vs brokerage account article covers why losses only matter in a taxable account to begin with.
Direct indexing and tax loss harvesting
Direct indexing means owning the individual stocks of an index instead of a single fund. A lot is one purchase of a security, with its own date and cost, and harvesting works lot by lot. A fund is one position that moves as a whole, but hundreds of separate stocks mean hundreds of lots, and some are almost always below their purchase price even when the index is up. That is the pitch: more chances to harvest, handled by software that sells and replaces them automatically.
Fees, account minimums and the quality of the wash sale tracking differ by provider, and the extra tax savings have to outrun the extra cost. For smaller portfolios, an index fund and a manual check once or twice a year, using a sheet like the one above, may give up little.
Tax loss harvesting: common questions
What is tax loss harvesting?
Selling an investment at a loss in a taxable account so the loss can offset capital gains and, within IRS limits, some other income. The money is usually reinvested in something similar, so the portfolio keeps its shape.
How does tax loss harvesting work?
A loss is realized by selling an investment for less than was paid, the loss offsets capital gains from the same year and, within IRS limits, some other income, and the money goes into a similar investment. Any loss the limits do not allow carries forward to later years.
What is the wash sale rule?
A rule that can disallow a loss if the same or a substantially identical investment is bought close to the sale. The IRS defines the window and what counts in Publication 550.
How many days does the wash sale rule cover?
Per IRS Publication 550, a wash sale involves a purchase of substantially identical stock or securities within 30 days before or after the sale. The publication has the full definition and what else counts as a purchase.
Can I harvest losses in a Roth IRA or 401(k)?
Generally no. The technique is built for taxable brokerage accounts, where realized losses show up on a tax return.
Is tax loss harvesting worth it?
It depends on the tax situation, the size of the losses and how long the money stays invested. Harvesting mostly defers tax instead of erasing it, so it helps most when there are gains to offset.
Sources
The specifics (limits, windows, definitions) live with the IRS and are best checked for the current tax year:
- IRS Topic 409, Capital gains and losses: loss limit, carryover, short-term vs long-term.
- IRS Publication 550, Investment Income and Expenses: wash sales and capital losses.
The example and the sheet figures are illustrations, not IRS figures.
This content is for informational purposes only and isn't personalized financial, investment, tax, or legal advice. Consult a qualified professional before making financial decisions.
← Back to DevsInvest