Pointy Haired Dilbert - Chandoo.org

Pointy Haired Dilbert - Chandoo.org

Excel Tips, Technology Tidbits and Business Insights

extract-hyperlinks-from-cell-excel-spreadsheet-formulaOften 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.

change-sort-orientation-excel-columns

how-to-sort-across-columns-orientation-change

You can sort data across columns instead of rows by changing sort options. If you ever had to sort across columns now you know a simple way to do this :)

Follow these steps for changing sort orientation:

  • Select the table you want to sort (just the data, not the headers as when you change sort orientation, you cannot set header rows)
  • Go to Data > Sort
  • Click on Options
  • Set “Sort Orientation” to “left to right” instead of “top to bottom” as shown below:
    sort-options-to-change-orientation
  • Click OK

Also see: How to count words in an excel cell, Fill only weekdays when auto-filling dates, Find unique items in a list

bullet graph - becoming a dashboard ninja using Microsoft excel conditional formatting and formulasBullet graphs provide an effective way to dashboard target vs. actual performance data, the bread and butter of corporate analytics.

Howmuchever effective they are, the sad truth is there is no one easy way to do them in excel. I have prepared a short tutorial that can make you a dashboard ninja without writing extensive formulas or installing unknown add-ins. So get out your shinobigatana and join me in a fresh excel sheet arena.

Before we create our first bullet graph, let us spend a few moments understanding these graphs. Stephen Few proposed bullet graphs as way to provide crisp view of “target vs. actual performance” numbers. Shown below is a sample bullet graph and how you would read it.

Sample bullet graph layout and how to read them

Read up more on this at PTS blog and on a Gauge chart that actually works.

Let us create your first bullet graph

Click here to download bullet-graph template excel sheet so that you can see while reading

Our technique of involves conditional formatting and simple formulas applied to a cell grid. Just follow these 4 easy steps:

Step 1: Prepare your data for charting

bullet-graphs-empty-cellls-step-1Since we are going to plot bullet graphs on a cell grid, we first need to normalize our data. I have chosen to plot each bullet graph on 20 cells in a row as shown in the raw grid shown to the right:

Assuming we have fictitious sales data like this:

bullet-chart-ninja-normalized-data-cells-Microsoft-excel-visualization

You can normalize YTD sales figures using a simple formula like this : ROUND(YTD-sales/target*20,0)

Now that we have our data steaming hot, lets brew the graphs

Step 2: Lets make the raw grid formatted based on data

Now we will take the raw 20 cell grid in each row and conditionally format these cells so that we have background of the bullet graph drawn on them.

For eg. If the normalized sales data for Bad range is 7 and for OK Range is 15 then,

We will highlight first 7 cells lighter shade of gray, next 8 cells gray and last 5 cells with darker shade of gray.

I have shown the conditional formatting applied to these cells below:
bullet-graph-excel-conditional-formatting

When we are done, a sample row looks like this:

bullet-graphs-building-background-step-1

We have our cell grids ready now, lets shoot some bullets. :)

Step 3: Plot bullets on our graph canvas

Our final step involves print a bullet symbol (either – or + or | ) in each cell depending on one of the following conditions:

1. If the cell position (1,2,3 … 20) is equal to Year ago value and cell position is less than YTD value print a + symbol
2. If the cell position is equal to Year ago value and cell position is more than YTD value print a | symbol
3. If the cell position is less than YTD value print a –
4. Else print a blank

See the formula below:
bullet-graph-MS-excel-if-formula

Download the excel template for bullet graphs to understand this formula better

Step 4: Show off your bullet graphs, awe your boss or colleagues, bask in your Ninja glory

Unfortunately, I cannot tell you how to do this. I can only teach you to be a Ninja, but you have to be one to charm people with your tactics. :)

Shown below is another variation you can try. Also, you can experiment with the symbols printed (instead of + - | you can try other ASCII characters, for more download the excel sheet containing bullet graph templates)

excel-bullet-charts-like-a-ninja-dashboard

Also try: Partition charts, Incell Graphs and much more.

In response to Making Incell charts better article, reader Tony mailed me an excel sheet in which he has modified the charts to display colors and negative values. This is pretty cool. Take a look at the chart below:

MS Excel Incell charts with colors and provision for negative values

MS Excel Incell charts with colors and negative values

Incell charts with negative values by displaying the chart in 2 rows
The trick lies in displaying the charts in 2 rows, one for positive values and another for negative values and then coloring positive row with green and negative row with red. See aside.

Download this example sheet to experiment with incell charts.

Thanks Tony for sharing this with our readers :)

What is your favorite charting trick?

1-incell-bar-charts-verticalizedI can never get tired of in-cell charts, whenever I get sometime, I try to experiment something on them. Here is an idea to design true incell column charts without using any add-ins or installing fonts. These charts can be fun to have on your project report or annual news letter or memos, they take as much time as munching a handful of M&Ms.

  Download excel chart containing incell bar chart example

1. First we will create in-cell chart using rept() the usual way

2-create-normal-incell-charts-firstThis is the simple step. For a sample data, we can use rept() excel function to repetitively print a symbol. Thus, by repetitively printing “|” (pipe) we can create incell bar charts.

REPT() example is shown below:

=rept("|",10) will print ||||||||||

2. Next combine several incell charts to create a column chart

We can combine various incell charts using excel’s concatenate() function or & operator. Better still you can use the concat() UDF. The trick here is we will delimit each chart with an ENTER key code by using char(10) as the delimiter. When used along with “wrap text” cell format this key code will force cell contents to a newline where the char code 10 is inserted.

3-now-create-combined-incell-using-concat

3. Finally rotate the cell contents by 900 to make the charts vertical

Just select the cell contents, hit ALT+1, and set the alignment formats so that the text is vertically aligned in the cell, and turn on wrap text.

4-finally-change-text-direction

That is all, you will now have an incell bar chart that is vertical like the one below:

5-final-chart

Pretty cool eh?

paste-everythingPaste or Ctrl+v is probably the most effective productivity tool available to us. But how well do you know “Paste”?, do you know that there are at least 17 different variations to paste data to your excel sheets? Surprised? Well, read this post to become a master paster :)

The post is divided in to 2 parts,

  • Basic Pasting Tricks
  • Pasting while Manipulating Data

    Basic Copy Pasting of Data


  1. Paste Values

    paste-values-aloneIf you want to just paste the values from copied cells, just hit ATL+E followed by S and V. Very useful when you want to strip away existing formatting and work with plain data.

  2. Paste Formats (or Format painter)

    paste-formats-only-1Like that sleek table format your colleague has made? But don’t have the time to redo it yourself, worry not, you can paste formatting (including any conditional formats) from any copied cells to new cells, just hit ALT+E S T.

  3. Paste Formulas

    If you want to copy a bunch of formulas to a new range of cells - this is very useful. Just copy the cells containing the formulas, hit ALT+E S F. You can achieve the same effect by dragging the formula cell to new range if the new range is adjacent.

  4. Paste Validations

    paste-validations Love copy those input validations you have created but not the cell contents or anything, just press ALT+E S N. This is very useful when you created a form and would like to replicate some of the cells to another area.

  5. Adjust column widths of some cells based on other cells

    You have created a table for tracking purchases and your boss liked it. So he wanted you to create another table to track sales and you want to maintain the column widths in the new table. You dont have to move back and forth looking for column widths or anything. Instead just paste column widths from your selection. Use ALT+E S W.

  6. Grab comments only and paste them elsewhere

    paste-commentsIf you want to copy comments alone from certain cells to a new set of cells, just use ALT + E S C. This will reduce the amount of retyping you need to do.

  7. Of course you want to paste everything

    Just use CTRL+V or ALT+E+P or one of those little paste icons on the tool bar

  8. Manipulating with copied data while pasting


  9. Add while pasting

    paste-with-additionFor example, if you have in Row 1 - 1 2 3 as values and in Row 2 - 7 8 9 as values and you would like to add row 1 values to row 2 values to get - 8 10 12, you can do this using paste special. Just copy row 1 values and use ALT + E S D.

  10. operations-while-pasting

  11. Subtract while pasting

    Just use ALT + E S S

  12. Multiply while pasting

    Just use ALT + E S M

  13. Divide while pasting

    Just use ALT + E S I

  14. Skip blank cells while pasting

    paste-skip-blanksThis is very useful when you are pasting data from that contains lots of blank cells. Instead of using filters or some type of if()s you can simply use ALT+E S B. This will remove all the blank cells from the copied cells before pasting it. Remember you can combine this option with other types of pastes (For eg. you can skip blanks while pasting values alone or skip blanks while adding the copied cells to paste area.)

  15. Convert rows to columns or columns to rows while pasting data

    transpose-while-pastingFor example you have large list of values in column A and you want to move (or copy) these values to row 1 across. How would you do that? Of course you can rely on trusty paste-special to do that little job for you. Just use ALT + E S E. This will transpose copied values before pasting, thus converting rows to columns and columns to rows.

  16. Paste reference to original cells

    If you want to create references to a bulk of cells instead of copy-pasting all the values this is the option for you. Just use ALT+E S L to create an automatic reference to copied range of cells.

  17. Paste text by converting it in to columns

    paste-text-import-wizard
    This option is very useful when you are pasting data from outside. For example, if you want to paste few lines of this blog post in an excel sheet but would like to see each word in a separate cell, you can copy the content here (CTRL+C), go to your excel sheet and use CTRL+V to paste the data and then click on the paste icon that appears at the bottom of the pasted cell and select “use text import wizard” option. This will launch the mildly powerful text import wizard of excel using which you can convert copied text to columns by defining some simple parsing conditions. The default options split text into words (by using space as a delimiter). You can use this option to convert most types of text including comma separated values, fixed width values. The text import wizard dialog looks somewhat like this.
    paste-text-import-wizard

  18. Paste live data from web

    If you want to import live data from web to your worksheets, you can use Excel web queries. This is a powerful tool using which you can create worksheets that can fetch data from web (or network resources) and display in your worksheet for you to process them. You can findout more about these by learning to create a mutual fund portfolio tracker sheet.

  19. What is your favorite paste trick?

    There are many more paste tricks that are hidden in excel, like pasting live xml data to your sheets, pasting images, objects, files etc. But I am more interesting in knowing your favorite pasting hack. So tell me, what is your all time favorite paste?

Interested to learn more? Show temperature using these thermometer charts, Get stock quotes to your workbook with one click, Master your ifs and buts - learn these 6 tips on if(), Project plan in 60 seconds, your time starts now!, Honey! I shrunk the bar charts and much more

skip-weekends-while-filling-dates-ms-excel-autofillOften you may want to fill a column only with weekday dates instead of all dates. Here is a simple trick you can use instead of writing nifty if formulas or manually entering the weekday dates.

When you auto fill dates by dragging mouse (or using menu > edit > fill > series > selecting “type: date”), just use weekdays only option as shown below.

fill-weekdays-dates-in-excel-only-howto

Now you dont have to create project plans with weekends in it :)