Shut off the power to the ceiling fan circuit at the main power panel.
Use a screwdriver to remove the switch housing cover to expose the switch wiring.
Make a sketch of the switch, wires attached to it and their color before disconnecting anything. This sketch will make reconnecting the new switch easier and less confusing.
Unbolt the switch from the switch housing. Some wires bolt to the switch and others plug into the switch. Unscrew the nuts for those that are bolted to the switch. Use a small screwdriver to remove those that plug into the switch. Insert the screwdriver into the hole with the wire and pull on the wire. The screwdriver will loosen the clamp holding the wire in place.
Contact the fan manufacturer for a replacement switch.
Use the sketch as a guide to reconnect the switch wires. Reattach the switch to the switch housing and bolt it down. Reinstall the switch housing cap and secure it using the cap screws and the screwdriver.
Turn the power back on and test the fan.