There is a trick called Charlieplexing (Charlie + multiplexing) which allows small number (n) of control pins can control n(n-1) LEDs.I found this link http://www.instructables.com/id/Charlieplexing-LEDs--The-theory/ from Google search with a keyword 'charlieplexing led,' and found the insctuctable explains this trick quite well.

If you look at a part like thishttp://www.mpja.com/download/18460op.pdfYou will see lots of common connections.If you a single LED on, you drive a left pin high (the anode connections) and a top pin low (the cathode connections).Want a whole row? Anode high, all cathodes low.Want a whole column? All anodes high, one cathode low.Anything else requires switching them in a pattern repeatedly over time.For instance, a diagonal line.Switch A1C1, then A2C2, then A3C3, etc. each combination briefly & repeatedly so to the eye it looks they are all on.Typically one would do something like set the columns, pulse the row on/off, & repeat thru the matrix.write columns, pulse row 1write columns, pulse row 2write columns, pulse row 3Chips like the MAX7221 do this cycling for you, and also control the current so no external current limit resistors are needed.