The Prophet (peace and blessings be upon him) used to fast most of the days of Sha`ban, but he used to stop fasting when he got close to the month of Ramadan. That is why Muslim scholars state that fasting is highly recommended in the early part of the month of Sha`ban until few days before the month of Ramadan.

Sheikh Ahmad Kutty, A Senior Lecturer and an Islamic Scholar at the Islamic Institute of Toronto, Ontario, Canada, states the following: As far as the Sunnah of the Prophet (peace and blessings be upon him) is concerned, we’re told by `Aishah, the Mother of the believers (may Allah be please with her) that the Prophet “used to fast most of the days of Sha`ban, but he stopped fasting when he got close to the month of Ramadan.” (Reported by Al-Bukhari and Muslim)

Based on this, it is considered highly recommended to fast in the early part of Sha`ban and stop fasting the last few days of the month.
The Prophet wanted to teach us an important wisdom that we should not join Sha`aban and Ramadan in fasting, rather we should keep the Ramadan fast totally separate from that of Sha`ban. Sha`ban fasting is only for preparation and warming up for the fasting in Ramadan, so we should not confuse the two fasts.