If you can provide the last 7 digits of the VIN number from both vehicles, it's possible to cross reference the part numbers.
Be aware there are very subtle differences between models. Case in point - the Getrag 260 tranny from the E28 535 and the E34 535 are virtually identical. Same housing, gear ratios, etc. Side by side, you would swear they are the same. The only difference is the construction of the output shaft. It's about 10mm long and has a different taper such that the E34 driveline is that same 10mm too long and won't center right. You'd likely discover this as you try to button up your project....
If the tranny part numbers aren't identical - I'd be extremely wary.
Jeff
Bellevue WA
90 535iM - not much stock remains. 3.7 liters, ported head, cammed, 3.73 diffy, M5 brakes, MAFed, yadda yadda yadda
86 Porsche 951 - Track Toy