Let's say a market is operating at equilibrium, with MSB=MSC, and a tax is imposed on the market. This would shift the supply curve to the left and cause a deadweight loss represented by the triangle on the graph. However, somewhere in a different market, the demand for a substitute good would increase and the surplus in that market will increase. Does that mean that some of the deadweight loss in the original market is canceled out by the increase in surplus in the new market?
I would say yes. In the extreme case: if there is a perfect substitute demand for the original good is perfectly elastic and its demand curve horizontal. That means that any tax imposed on the original market will lead to zero demand for the original good. All demand would move to the new market due to perfect substitutability. The entire surplus of the original market is deadweight loss. If both demand and supply moved to a new market they could replicate the original market there. The deadweight loss would be compensated completely by the surplus in the new market.
If the new market has preexisting demand not all additional demand from the original market could be satisfied at the same price point as in the original market leading to a welfare loss. The demand curve in the new market would move to the right but not sufficiently to compensate the deadweight loss incurred in the original market.
Correspondingly, the less elastic the demand for the original good is, the less demand can move to the new market and the less deadweight loss can be cancelled out by the new or increased surplus in the new market.