micro intermittently won't start

When I place something in the microwave, set the time and press start, sometimes it starts runs and cooks fine. Other times the timer starts counting but nothing else happens.
I was told there are some kind of switch or sensor to tell the door is closed before it will start, is this the problem? Does the timer counting but nothing else help troubleshoot?