For mass combats, I use statistics instead of rolling.
Zappo's Oversimplified D&D Mass Combat Rulez
First of all, units are treated as a single character, no matter how large. A unit must be comprised of characters with the same stats (to-hit, AC, equipment, HP...). A unit can only attack a single target at a time, be it a character or another unit. Units act simultaneously - that is, there is no initiative and each unit attacks before resolving damage.
Dealing damage
I assume that an attacking unit rolls an even spread of to-hit rolls. This means that if a unit with +X to-hit attacks a unit with Y armor class, the percentile of soldiers that will hit is
(105 + 5X - 5Y)%
, which, trust me, is less complex than it sounds because you basically figure what dice roll they need to hit and the chance they roll that high. Both calculations should be nigh-instantaneous in the mind of any D&D player.
Chance to hit can't be less than 5% or more than 95% regardless of AC.
All soldiers that hit deal damage. Just take the average damage a soldier would deal.
Taking damage
When a unit takes damage from a character, resolve normally.
When a character takes damage from a unit, multiply the number of soldiers that hit by their average damage. For large units with ranged weapons, getting seriously hurt without rolling will put Holy Fear into the PCs fairly quickly. Remember that damage reduction applies multiple times, though.
When a unit takes damage from another unit, figure how much damage it takes. The damage is distributed so as to send as many enemies as possible to -1 HP. Extra damage is wasted.
Combat example
Unit A (40 men, with +2 to hit, AC 12, 4 hp, dealing 1d8 damage)
Unit B (20 men, with +1 to hit, AC 14, 5 hp, dealing 1d8+1 damage)
Unit A's soldiers need a 12 to hit unit B's soldiers. So, 45% of them hit. This means 18 men, who each deal 4.5 damage, for a total of 81 damage.
Unit B's soldiers need a 11 to hit unit A's soldiers. So, 50% of them hit. This means 10 men, who each deal 5.5 damage, for a total of 55 damage.
Unit B takes 81 damage, and one of their men can absorb 6 damage before being at -1, so 81:6 = 13 of them are down.
Unit A takes 55 damage, and one of their men can absorb 5 damage before being at -1, so 55:5 = 11 of them are down.
Where's The Randomness?
First of all, the generals of each side don't know the exact stats of their enemies. This is the "randomness", in that if you order to attack you may win, or maybe not.
Secondly, I haven't covered morale rules, which I feel should have some dice rolls because troop morale in fantasy heavily depends on heroic actions by single soldiers, and thus is less dependant on the laws of large numbers.
The main advantages of this system are its speed, upwards scalability, and easy compatibility with standard D&D rules. Notice that unless there are PCs involved, there is no need to roll dice. This is designed on purpose to allow the DM to quickly do combat that doesn't involve PCs in the background.
For its oversimplification, though, you may not want to use it for campaigns that revolve around mass combat.