Arduino mega or shift register for 40 LEDs all on/off or individually on/off

OK let's look at your initial request:-

All LEDs on at once, off at once
Dim blocks of LEDs (10, 20 at Once) while others stay on
Flash/blink all at once, many at once, or rows one at a time
Individual on/off while others remain in same state
5 inputs will be read and will determine the display pattern

If you need to dim the LEDs in blocks but need individual control over them then your requirements are:-
read 5 inputs
individually control the brightness of 40 LEDs

The rest is just duplication and obfuscation.

Coupled with the fact that you don't want to source the LED current from the arduino I would say you would have to either:-

  1. Implement a software PWM for the arduino to allow all pins (or at least 40 of them) to have individual PWM outputs.
  2. Use a simple shift register (5 of them cascaded) and implement the PWM in software like in the shiftPWM library
  3. Use a chip that will give you a PWM output like the TLC5940 or the PCA9685. As these handle 16 outputs then you will only need three of them.

So those are your options, choose what you are most comfortable with.