Often my work involves processing web page data in excel sheets. This includes extracting the hyperlinks from cell contents. There is no formula for extracting hyperlinks though, you can right click on cell and choose “edit hyperlink” to see which address the cell is linking to. But that is a tedious process especially if you are planning on using the hyperlink for something.
Here is a handy user defined function in VBA for getting hyperlinks from a spreadsheet cell:
Function getURL(forThisCell As Range) As String
'VBA UDF for getting URLs from a cell if any
retVal = ""
If forThisCell.Hyperlinks(1).Address <> “” Then
retVal = forThisCell.Hyperlinks(1).Address
End If
getURL = retVal
End Function
Bonus tip: You can create hyperlink on a cell using “hyperlink()” spreadsheet function. The syntax is simple. =hyperlink("http://chandoo.org/wp","Pointy Haired Dilbert") will create a link in the cell to this blog.
I am fascinated by board games. They provide immense fun, anyone can enjoy them, they are unpredictable and best of all they are great value for money. That is why whenever I get sometime I experiment with simulating games to know them better [read Why Monopoly board game is not as random as it appears]. So, out of curiosity I have created an excel sheet that can generate bingo / housie (housey) tickets - 24 of them at a time. To get new set of tickets you would hit F9 (recalculate).
Download Bingo / Housie ticket maker excel sheet
Note that these are Bingo UK / India / Australia variant I am talking about, not the US 5*5 type of bingo tickets.
Read on if you want to know how this is done:
According to Wikipedia:
A typical housie/bingo ticket .., contains fifteen numbers, arranged in nine columns by three rows. Each row contains five numbers and four blank spaces. Each column contains either one, two, or very rarely three, numbers:
* The first column contains numbers from 1 to 9,
* The second column numbers from 10 to 19,
* The third 20 to 29 and so on up until the last column, which contains numbers from 80 to 90.
I have removed number “90″ from the list in order to reduce some complexity in generating the tickets.
The problem is now to “generate 15 random number between 1 to 89 and fill them in 15 random spots in a grid of 3 rows by 9 columns such that each row has exactly 5 numbers”
Now I could write a function in VBA to do this, but I wanted to do this only using formulas. So I started breaking the problem.
Once we select any random 5 cells in a 9 cell row, we will fill them with bingo numbers. Now, excel has a function to generate random numbers between 1 to 9 (=round(rand()*9,0)), but this is not good for us since each time we call this function we will get a random number between 1 to 9, where as we need a 5 random numbers without repetition between 1 to 9. The function is memoryless and could repeat numbers when called 5 times.
Instead we can list all the possible “5 cells with numbers and others are empty” combinations of a 9 cells region and select a random combination every time. There are essentially 9C5 i.e. 126 ways in which you can select any 5 cells out of 9 cells (without repetition of course).
So I listed all these combinations in a table and then randomly selected one of the combinations. You can see the first five such combinations in the image below:

Selecting any five cells out of nine cells
Now I created a 3*9 region and filled the cells with 1s or 0s, “1″ when the cell in bingo ticket is supposed to have a value and “0″ if the cell is empty as shown below:

The trick here is that first column in our 3*9 bingo ticket has any number(s) from 1 to 9, second column has any number(s) from 10 to 19 …
Again, the challenge is the numbers should not repeat, otherwise we could simply use rand()*10, rand()*10+10, rand()*10+20 ... to generate the numbers.
This time it gets even more trickier because each column can have either no values, or 1 value or 2 values or 3 values.
The ticket generation logic now looks like:
As you can see, it is easy when the column has no or 1 value in it. But when the column has 2 or 3 I used the combinations trick described earlier.
First I created all 2 number combinations and 3 number combinations. Since the numbers on Bingo ticket are always sorted from top to bottom in a column, I just had to list down 45 combinations (10C2) for 2 numbers and 120 combinations (10C3) for 3 numbers.
The rest of the details are small enough that I can leave them to your imagination. So when the ticket is generated, it looks like this:

Remember to download housie / bingo ticket generator excel sheet and print your tickets at home. Just F9 to generate new set of tickets. Un-hide the rows from 43 if you want to see how this is done.
Like this post: Consider digging it or bookmarking it on del.icio.us or better still subscribing to my feed, its yummy ![]()
Reader Nikhil Shah asks in an email:
Dear Chandoo,
I have some Error In Excel sheet.
Problem :-
I have a locker number 01234 567890, in Excel it will be displayed as 01234 567890 with the space. However if it was entered as 01234567890, Excel will display it as 1234567890, without the leading zero. If the data has been read in from a text fill in could be formatted as text and still show 01234567890.
Now I want my locker number see with zero in excel sheet,How it possible,please help me with example.
You can force excel to format numbers the way you want using “format cell” feature. Just select the cell with number you want to format and hit ctrl+1 (or right mouse click > format cells) and go to Number tab in the dialog box. Select “custom” category and enter format as 000000 00000 (6 zeros followed by a space and then five more zeros) as shown below. Hit ok to set the format to display locker number as you desire.

Also, try these things:
Do read Using Custom Cell Formats in Excel - Tips & Tricks to findout how to format dates, currencies, special formats etc.

Often we work with large data sheets and it becomes tedious if you want to compare data / formulas etc. You can try split (menu > window > split or alt+w+s) to break the sheet in to two. But there is another cool thing you can do, open a new window for the spreadsheet. Just press Alt + w + n (menu > window > new window) to open the same spreadsheet in 2 windows. Any changes you make in one window are immediately visible in another window(s).
Bonus tip: you can do the same thing with WORD and POWER POINT as well, cool eh?
![]()
Would you like to spend next 5 minutes learning how to create an excel sheet to track your mutual fund portfolio?
NOTE: I have updated the sheet to fix a formula error, download it again if you need to.
We will use 2 simple excel features to achieve this - web queries and vlookup()
[click here to learn more about web queries in excel]
When you finish creating the table, it would look something like this:
Since AMFI returns data in a text file with ; as delimiter, I had to parse the fund names and navs out of it using a combination of search(), left() and mid(). I will not get in to the details of how its done since you may have to process your data differently depending on source.
Finally when the processing is done, we will have a table in the second sheet with all fund names and latest navs.
The formula for latest NAV can look like this:
=vlookup(c1,sheet1!c1:d6000,2,false)
Remember to use false for last parameter since fund names may not be sorted in alphabetical order on your source web page.
Now we will repeat this formula for all the rows in latest nav column. I have built my portfolio tracker to track 20 funds at a time. Also, you can simplify formulas using named ranges.
current value = latest nav * units held
profit/loss = current value - purchase value
profit/loss % = “profit/loss” / purchase value
You can add some conditional formatting to beautify the table (like turning text blue for profits and red for losses etc.)
Feel free to download mutual fund portfolio tracker excel sheet I have created and play with it.
Few ideas on how you can enhance this:
Here is a ridiculously simple workaround for those of you trying to generate an organization chart in excel:
Use google org. chart widget instead
[If you are reading this in a feedreader this post may not display properly, visit the post page instead.]
Open a new google docs spreadsheet (or work on the example organization chart spreadsheet I have created) and enter your organization employee data in the format shown below: (enter employee name in column 1 and manager name in column 2)
Create a organization chart gadget (menu > gadget > organization chart “add to sheet”), once done, the org chart should look something like this:
Its very easy to do and saves you a lot of time. If you need some example you can access the organization chart spreadsheet I have created.

Here is a simple to trick to beat the 56 color limitation in excel when you are designing a chart: use picture files (jpg, gif, png etc.) to fill the chart area.
You will no longer have to worry about limiting your project report / website / annual report etc. colors to the 56 that excel has.
1 + 3 steps to get more colors in excel charts:

Also: Download 73 beautiful excel chart templates | Art of excel charting | Become a conditional formatting pro