The halfshafts are all the same, even the 280ZX shafts. One of the Hybridz members compared a range of years and determined that, but, unfortunately his web page with the data is gone. The 240Z's seem to be slightly narrower between the wheel flanges than the 280Z's, but that has not been confirmed. It's not the halfshafts, it's the cars. The binding issue doesn't seem to be a big problem but you can find threads about people grinding areas of the halfshafts to shorten them at full compression.
In short, all you really need is the correct pinion shaft flange. Or a 75 280Z propeller (drive) shaft.
Or, maybe there's a flange that you can swap on to your 240Z shaft, see link below. I haven't gone through the actual measurements so don't know for sure if this guy's parts work. Some of his information is wrong, like the part about the 79-83 differentials. 76-83 R200's all have the same dimensions, I have had several across the full range. I've also seen square flanges (78) and circular flanges (76) that fit the same way. Shape does not correlate to fit.
Anyway, worth some measuring. Check the bolt hole diameters. Make sure the u-joints will fit. Good luck.
https://jagsthatrun.com/products/adaptor-flange-for-datsun-z-v8