It's usually best to take ranitidine for a short time. You might take it for a month or two, for example, until your stomach heals. Some people may take it every now and again when they have symptoms.