I had this problem on my '82 240D. It drove me crazy. I finally replaced the unit on top of the valve cover that contains two vaccum switches. I believe they are called vaccum cross-over or vacuum transition switches. They were very worn out AND very easy to replace. I also checked the vacuum unit on the transmission which also needed to be replaced.
Finally I did a trans service (replaced the trans filter, fluid and gasket) and it ran like a champ. I was amazed actually how well it shifted.
My 2 cents.