(Oops, my text got mixed up. This is what I meant to write:)
If the word sounds like it starts with a vowel we put 'an' before it; if it sounds like it starts with a consonant we put 'a' before it:
H
When the h is pronounced (thus the sound of a consonant sound starts the word), we put 'a' before it, like 'a half'.
When the h is not pronounced, thus the word sounds like it starts with a vowel, we put 'an' before it, like 'an hour'.
U
When the u is pronounced as a y (as a consonant) we put 'a' before it, like 'a university'.
When the u is pronounced as a vowel we put 'an' before it, like 'an ulcer'