It seems spreadsheets & dinosaurs on a collision course. How else can you explain Jon’s XKCD Velociraptor problem solved with Excel and now this. Debby, an alert reader of our blog sent me this email yesterday.
I need an algebraic formula to solve this in Excel
I have 5 heads, 5 bodies, 4 arm sets, 4 leg sets and 3 tails. I need to see if I can create 1000 dinosaurs from these, and if that’s too many AND I need the 5 digit groupings to prove it and create them.
basically Xa*Xb*Xc*Xd*Xe=1000 – I’m not supposed to go over 1200. […] And then I want the 5 digit combinations if possible – right now they are trying to do the combinations by hand – would be awesome if we could do it in Excel.
Ladies & gentlemen, let’s fire up Excel
There are two problems to solve.
(1) How many dinosaurs can be made?
(2) Listing of all such dinosaurs.
The first one is easy.
We just multiply the number of heads, bodies, arms, legs & tails. I know this sounds biologically impossible. But in math everything is possible. So we get =5x5x4x4x3 = 1200
That means, given the body part variations, we can generate 1,200 dinosaurs. Some of them may be hideous, but 1,200 of them nevertheless.
Making 1200 dinosaurs in Excel
This is very simple. We just use the MakeDinosaur() formula in Excel.
Of course, I am kidding. There is no MakeDinosaur(). Instead, we can use the all powerful INDEX().
Let’s say, we have listed the various parts in a range like this:

Now, each of those ranges are conveniently named as heads, bodies, arms, legs and tails.
Next, in an empty column, we list 1200 running numbers. Side note: we could do away with this step and use ROWS() function. But dinosaurs don’t mind helper columns.
Let’s say, these running numbers are in H4:H1203.
We now use our T-rex sized INDEX formula.
=INDEX(heads,(H4-1)/240+1) & INDEX(bodies,MOD((H4-1)/48,5)+1) & INDEX(arms,MOD((H4-1)/12,4)+1) & INDEX(legs,MOD((H4-1)/3,4)+1) & INDEX(tails,MOD((H4-1),3)+1)
This generates all combinations of dinosaurs.
Let’s dissect the t-rex. Shall we?
- The formula is a concatenation of five INDEX functions.
- Each fetching one body part viz head, body, arm, leg or tail
Head portion:
Formula: INDEX(heads,(H4-1)/240+1)
What it does? There are 5 head choices and 1200 possible dinosaurs. That means, each type of head is attached to 240 (1200/5 = 240) dinosaurs.
So, we simply take the number in H4, divide it with 240 and figure out which head to use.
Body portion:
Formula: INDEX(bodies,MOD((H4-1)/48,5)+1)
What it does? So we now have 240 possible dinosaurs with a given head. And we have 5 types of body. That means 48 dinosaurs per each type of body given a head type.
We could use INDEX(bodies, MOD(H4-1,240)/48 +1) to get the corresponding body number.
Alternatively, we can use the simplified version INDEX(bodies,MOD((H4-1)/48,5)+1)
Why does it work? That is for you to figure out. There is a reason we are not extinct yet.
Remaining parts:
We use similar logic to fetch other body parts.
Download the dinosaurs
Download the 1,200 dinosaurs. Be careful, #14321 is a bit loony. She almost bit my shift key.
How would you make ’em dinosaurs?
Of course, we could use VBA, other formulas to make these nasty reptiles. What would you do if someone asks you create a few dinosaurs? Share your recipe in the comments.
Stop stomping & start succeeding @ spreadsheets
Do you resort to manic stomping and rampage when a spreadsheet goes astray? Take things into control. Sharpen your spreadsheet skills. Check out below pages:














17 Responses to “Custom Number Formats – Colors”
You are right, Chandoo. I was playing with the colour numbers last week and some of them don't appear different from each other. Others are totally different from yours.
@Duncan
Each version of Excel, post 2003, renders colors slightly differently
Different language versions may also have different default color palettes
Hello in french
excel 2010
colo1 = couleur1 = black
[couleur1]; [couleur2]; etc..
@Hui, thank you very much again for this great post.
However - under Excel 2007, Hungarian version your solution does not work with color names. I've tried both English and Hungarian names, but drops an error message "not valid formats"
Do you have any idea how to solve this issue?
thanks in advance
@Andras
Without a Hungarian version of Excel 2003 I don't think I can assist
Have you tried using the colour numbers? I couldn't get the names to work (despite using an english version of excel). but it did work with the numbers though. I left out the "u" and was easily able to produce burgundy using [color9]
Here a possible solution: find an English version of Excel, write there the formats using English names, then open the file in the Hungarian version and see the translation.
In Excel 2007 I can't get the colour names to work e.g Sea Green but the numbers do e.g color3 - colour3 does not work so I must bow to the country that has stolen my language (ha ha!)
Hey chandoo, nice Tip!
Wouldn't be easier just apply some conditional formatting for negative numbers and another for positive numbers? Or there's some cases that you can't do that?
Unfortunately the TEXT function doesn't color the cell as number formatting does.
Hi Hui,
Great post Sir, love the new way of formatting with color numbers.
I am using 2007, and it leads me to the last color number 56.
Thanks Hui.
[…] explains how to set up custom number formats with a wide array of […]
Thanks Hui - works a treat!
Thank you, very helpful.
Trying to figure out if it is possible to apply color only to a part of the cell?
E.g. I have a value formatted as Accounting with a currency symbol.
Those I find somewhat distracting though necessary. If I could make them less obtrusive by coloring them gray while the number would stay black, that would be great. Tried tinkering with the format string, but didn't get the desired result. Single color for complete cell value works, but coloring just part of it could not be achieved. Maybe somebody managed that?
Exactly what I was looking for - thank you!
colour in the Australian doesn't work - we have to go American and no problem.
I always thought is was 56 colours notice you have 57. Cool.
thanks
Analir Pisani
Customised Microsoft Office Training Specialist
Sydney - Australia
http://www.azsolutions.com.au
Thank You!