While the random treasure table in the 3.5 DMG p.52 is helpful, I find it a little... wonky. The ranges are a little crazy and arbitrary. What follows is my attempt to come up with a more formula-based approach to rolling up random treasure that makes a little more sense.
For starters, the mechanic used is a familiar one: roll a d20, add bonuses, and try to hit (or exceed) a target number (hereafter called a "Rarity Class" or "RC" for short). (Sound familiar?) The "bonus" added to the d20 in all cases is the Encounter Level (EL) of the monsters / trap / etc. just defeated. The EL is also frequently used to compute amount of treasure.
You basically make N rolls (one for each entry in the table below). Under Quantity, where you see "dEL", it means get a die with at most EL sides to on it. If the EL is an odd number, round down (i.e. at EL 5, they're picking up 1d4 Gems). If the EL is 1, they get at most one item. When you get up past 12, use a combination of two smaller dice to get the number you need, e.g. d14=d6+d8, d16=2d8, d18=d8+d10, d20=d20 or 2d10. (Alternatively, you could use a a d14 or a d16.) Any time you see (EL/N), always round down with the minimal number being 1, making no die roll necessary; usually, it means they get just "one" of something.
|Copper||6||dELx100 + d%||N/A|
|Silver||11||d(EL/2)x100 + d%||N/A|
|Gold||16||d(EL/3)x10 + d1s-place||N/A|
|Platinum||27||d(EL/4)x10 + d1s-place||N/A|
(Regarding the high RC of Platinum, the SRD says you're no more than 5% likely to get platinum until level 7.)
Why I like this better: mixture of coins, quantity of coins is a little more plausible (not always rounded to 10, 100, 1000, etc.), more formulaic, the variants below are nice.
Expiration: Should you arrive at a point where the EL is so high that it will automatically succeed in gaining the party treasure, that form of treasure is now "expired"; don't bother rolling for it any more. (You may even wish to "expire" a form of treasure a little earlier.) This variant is designed to prevent high-level groups from getting swamped with copper pieces and mundane items.
Critical Successes: If you roll a natural 20 for a particular form of treasure, roll again to confirm the "threat". If the second roll succeeds against the same target number, double the quantity that they would receive. (Alternatively, give them some other "great" success, like a long-standing wishlist item, an intelligent item, or an artifact.)
Critical Failures If you roll a natural 1 for a particular form of treasure, roll again to confirm the "fumble". If the second roll fails against the same target number, give them a "nasty" item. (Examples: the coins are leprechaun gold / made of wood / covered with contact poison, the gems are worthless glass, the art is counterfeit / hot, the mundane item falls apart at first use, the magic items are cursed / intelligent in a really annoying way.)
This suggestion comes from Rob in the U.K. He had this idea on how to prevent higher-level parties from being overwhelmed with lower-order treasures:
Rolling for magic items:
Roll first for minor item. If you don't get one, stop there.
If you get one, try rolling for a medium item - if you don't get one, stop there (i.e. just get a minor item), If you get one, ignore the minor item and carry on. i.e. don't roll for the actual item on the DMG tables until you know whether its going to be a minor, medium or major item....
While this approach will generate lower amounts of treasure it will be more selective - i.e. less copper and silver, less mundane items at even medium ELs.
(My $0.02) One other way to view it is: Start with the highest-valued item the party could earn in a given category and proceed down the list to the lowest-valued item. Stop as soon as they get something.
ERRATA: d(EL/2 - 3) starts giving multiple major items too soon. It looks like the only way to do quantity of major items is piecewise:
Level # of major items 13-19 1 20-23 1d2 24-27 1d4 28-29 1d6 30-31 1d8 32-33 1d10 34 1d12 35 2d6 36 1d6+1d8 37 2d8 38 1d8+1d10 39 2d10 40 1d10+1d12
Note that although this is balanced in terms of the total GP value of a treasure lot, there are fewer major items overall at epic levels compared to the SRD or ELH, because the numbers of minor and medium items, coins and goods are still increasing past level 20 (which they aren't under the SRD or ELH). If the DM finds this makes specific major items too hard to find, I suggest increasing the GP limit of one or more metropolises.
Chris has also done a formidable amount of work making a spreadsheet that spells it all out: