Really depends on your code and the connected hardware, neither of which we can see.
The pins on Teensy 3.5 are 5 volt tolerant when used as inputs, but Teensy 4.0 is 3.3V only. So if you have any hardware connected which drives the Teensy 3.5 pins with 5V signals, that would be the main concern. You can damage the Teensy 4.0 hardware with strong (low impedance) 5V signals.
Code-wise, a first check would be to simply change Tools > Boards to Teensy 3.5 and click Verify to check if your code compiles. If you've used only the normal Arduino functions and libraries, it will probably work. But there are some exceptions. The main one that comes up is pin muxing, like row-column connected keypads, where a delay is needed between changing the rows and reading the columns. Teensy 4.0 is much faster, so if you have speed sensitive code, it might need delays added.
All the features of both boards are explained on their product pages. Maybe comparing them side-by-side might help?
https://www.pjrc.com/store/teensy40.html
https://www.pjrc.com/store/teensy35.html