How to wire a ceiling fan to a switch that controls outlet
You run a cable from the ceiling to either the switch or the receptacle. You then need to change the connections in the outlet, and if you route to the switch you will need to change those terminations too. If you route to the switch you will lose the switched receptacle.
There are so many actual ways to make the terminations at the receptacle that you would really need to post a picture of the wires connected to the receptacle to get advice which terminations to intercept.
But basically if you route to the switch you get a new receptacle and connect all the blacks to the gold screw (small slot) side of the receptacle, and the whites to the silver screw (tall slot) side. Then at the switch connect whites together and blacks to the switch.
If you run to the receptacle you can either reconfigure to eliminate the switched receptacle or not. This is where a picture is needed, but essentially you connect the new cable to the terminals or wires connected to the switched portion of the receptacle. You will need to concerned the code limits the number of wires in a box based on size of the cu. in. of the box. Gauge of wire is needed to calculate.
Edit. You should replace the receptacle, re-using stab back receptacles produces questionable results. You will also need a few new wire connectors (tan wingunts) and a 4&quot; piece of white wire.
Turn off the power, connect all ground wires together and pigtail to devices.
At the switch where you ran the new cable connect white to white using a yellow or tan wire connector, and blacks to the switch.
At the receptacle box remove the white from the red wire connector, and all the wires from the old receptacle. Connect all black wires and a black jumper together in a new tan (or red) wire connector. Form a hook at the end of the black jumper wire (using a hole on the wire strippers) and connect to a brass screw on the new receptacle.
Connect all the white wires and the new 4&quot; jumper together in a new tan (or red) wire connector, connect the jumper to a silver screw.