Can I substitute oil for butter in a cake recipe?

When I make cookies, I substitute the eggs for the amount of oil that is asked for, but I do not know about butter