Electrical Questions? Ask an Electrician Online.
This is due to a loose connection, or a breaker that is bad or going bad. If you are comfortable doing so, please tighten all connections in your electrical panel. It is safest to tighten the wires on the breakers with the breakers turned off. Don't forget to check the neutral wires in the panel as well. It wouldn't be a bad idea to temporarily swap the breaker for the affected circuit with another breaker from your panel.
Since you replaced a switch and noticed changes afterwards, there could be a loose wire in the switch box. If not there, then definitely somewhere along the affected circuit. Unfortunately, these types of things can be time consuming and frustrating to track down. I would look at nonworking outlets to make sure the wires are not pushed into the small holes on the back. If they are, it would be a good idea to reconnect them using the side screws. You may have to open a working outlet to find this problem.