I want to know if this is the correct way to do this.
There is a switch that controls a single receptacle in a double receptacle outlet across the room. Power comes into the switch box via 3-wire (black/white/ground). There is a 4-wire (black/white/red/ground) going to the switch via the attic. The whites and grounds are nutted together respectively. The blacks are also nutted together and pigtailed to the black screw on the switch. The red is connected to the other side of the switch. Over at the outlet, the red wire is connected to the top (switched) receptacle, and the black to the bottom (and the white is connected to both of course and it is grounded).
I want to install a ceiling fan with a light fixture on separate switches. The switch is on an interior wall but the outlet is on an exterior wall. The 4-wire passes right overhead (in the attic) of where I the ceiling fan will mount. What I want to do is cut the 4-wire near where the fan will go, route the 4-wire into the fan box, and replace the single switch with two switches that switch the black AND red wires that now go to the fan and light. Then, run a new 3-wire up from the switch box, with has constant power, to a new junction box and jumper the new 3-wire to the old 4-wire, leaving the red unconnected. Then, I will replace the outlet such that both receptacles are powered from the black only and leave the red disconnected.
Being an electrical engineer, I know that this will work from a power-distribution standpoint, but are there code violations or better ways to do this?