When your fluorescent light flickers or makes a loud and annoying hum, a degrading ballast is the cause. The ballast takes in electricity and then regulates current to the bulbs. A typical ballast will generally last about 20 years, but cold environments and bad bulbs can decrease this lifespan significantly. You can get a new ballast at a hardware store or home center and install it in about 10 minutes. However, buying a ballast can be expensive ($15 to $50), so consider pricing a brand-new fixture for comparison.
Start by flipping off the circuit breaker or unplugging the light. Remove the bulbs and open up the fixture as shown in Photo 1. There will be four to eight wires coming out of the ballast. Photos 2 and 3 show how to remove the old ballast from the fixture. Confirm that the new ballast matches the old one and then install it as shown.
After mounting the new ballast, replace the ballast compartment cover and bulbs, and it should be good for another 20 years.
Click image to enlarge.
1. Unplug the fixture or turn off the power at the main panel. Remove the ballast compartment cover to expose the internal wiring and ballast. The attachment method for ballast covers varies widely among manufacturers. It may be attached with nuts or clips or simply snapped into place.
CAUTION:
Turn power off at main panel before performing repair.

2. Snip the old ballast wiring several inches from the end of the ballast with a side-cutting pliers or wire snips. Cut all the wires connected to the ballast.

3. Unscrew the ballast-mounting nut and drop the old ballast free (the ballast will have either one or two mounting nuts). Hold on to the ballast with your free hand to keep it from falling out.

4. Mount the new ballast in the fixture. Strip the electrical wiring back 1/2 in. and connect the matching-colored wires with twist-wire connectors.
TIP
Click image to enlarge.
Click image to enlarge.
Take the old ballast to the store with you. Compare the new and old ballasts to verify that the wiring diagrams, voltage and current match before installing the new ballast.