Hi. My name is*****'m looking at your question now and will post my answer or ask for more information here in a short while.
If you look at Box 1.29 here, you will see that where you sold what was a previous main residence within the 36 months before the purchase of a new man residence, you don't have to pay the 3% stamp duty surcharge. You don't need to have been living in the previous main home at the point of sale but it must have been your previous main home at some point during the 36 months leading up to the purchase of a new main residence. See the eleventh paragraph in section 2.8 here for the definition of a previous main residence, substituting 36 months for 18 months. The key words are "at some point".
I hope this helps but let me know if you have any further questions.
I'm just following up to find out if my answer helped or if you have any further questions.