Get your taxes done using TurboTax

the debt on the property (HELOC or primary mortage) has NO impact on the capital gains

 

Selling price minus  (original purchase price plus selling closing costs plus capital improvements ON TEH PRIMARY RESIDENCE since purchase) = capital gains. 

 

also, and I appreciate this wasn't part of the question, the HELOC interest is NOT deductable on Schedule A, as the money was not used to substainionally extend the life of your personal residence.  the HELOC interest is deductible on Schedule E to the extent the proceeds were invested into the investment property. .....