A misfire can cause your car to run rough. There are many possibilities. Vacuum leaks are more obvious when the car is at idle. If your engine light on when the car is acting up, it is fuel/emission related which is another possibility. Have you had a tune-up recently? Loose wires can also be a cause.
Feel free to pass by the shop and I can take a look for you, at no charge to point you in the right diretion.