Hi & thanks for using our service. I'll do my best to give you a complete & accurate answer. Please ask me to clarify anything you don't understand.
You'll need to complete Form 4797, but the gain will be based upon the net book value compared to the net selling price.
So all of the depreciation will affect the gain.