About the author

Image of Philipp Kowalski

Philipp Kowalski is a self-taught Excel-lover, project manager and blog-owner. Besides developing "beautiful" solutions in MS' premier spreadsheet tool, he loves his fiance, his cats and surfing the net. He is CEO and owner of Inservo IT, the company behind Excel-King. He's also available on Twitter and YouTube. If you like this website, please leave a comment. If you want to know more visit the forums or look into the about section of this website.

Error
  • Error loading Modules:
Okay, folks. Today I want to show you a really cool trick I learned recently. It’s all about images and how to spin them with an Active-X-Control

Basically this will be achieved through using names. Let’s start!

Assuming we have a file where we e. g. want to spin the flags of countries. This could be the case if you are creating dashboards (sign up for my newsletter if you don’t want to miss my upcoming “14 days to dashboard mastery”) and want to show the corresponding national flag to the country that is reported in the dashboard.

So I have downloaded the following two images from Inconfinder.net:

1266310371_dooffy_design_icons_EU_flags_Germany

 

1266310356_dooffy_design_icons_EU_flags_United_Kingdom

The next step we have to take is to define several ranges that we need. Altogether there will be four of them and below you can find the area and what they are needed for:

  1. SpinCountry – Cell A1: This will be the linked cell of a later to be inserted spin button with which we will toggle between the images
  2. DE – Cells A3:C14: This will hold our image of the German flag
  3. UK – Cells E3:G14: This will hold our image of the English flag
  4. CountryImage: This named area will NOT be linked to a cell but to a formula (we will come to this later).

So please set up the first three areas by selecting the cells mentioned above and enter the name left of the edit bar in the field that usually shows the cell reference.

See the screenshot below to see its position in Excel 2003 (2007 is very similar):

Define names

What we will do now is to insert the spin button and link it to the previously mentioned cell labelled “SpinCountry”. Do so by going to your developer ribbon then into the controls section and select the spin button Spin button from the form controls submenu (click the little down arrow below the insert button)). Click and drag it until it has the size you want.

Right click this button and select  Format Control.

By the way in Excel 2003 this will be handled through the Control toolbox which will appear if tick the check mark in front of it by going to View – Toolbars

The Maximum value should be set to 2 and the Minimum value to 1, because we have only to images we want to scroll through. Enter the name of our previously created SpinCountry cell into the field cell link

Format control dialog box

The next step would be to insert the images into our spreadsheet document. Put your cursor to cell A3 and then select Insert – Picture – From File. Choose the German Flag which you have hopefully saved to your hard disk (if not, here it is again)

1266310371_dooffy_design_icons_EU_flags_Germany

Make sure that it covers the area A3 to C14 (which we have previously defined with the name “DE”). You can make sure that it “snaps” to cell borders by holding down the ALT key on your keyboard and then using the little circular handles in the middle and on the edges of the image. This way, you are able to resize the image exactly to the size of the named range.

Okay, let’s proceed with the second image (and yes, here it is again):

1266310356_dooffy_design_icons_EU_flags_United_Kingdom

Resize it as described above but this time it should cover the area named UK (cells E3 to G14).

Now comes our little “magic” trick: We will define the fourth and most important name of our table, CountryImage. But this time this is not an area but a formula.

I will describe this for MS Excel 2003 but the way for Excel 2007 is very similar: Go to Insert – Name – Define. In Name for the worksheet enter CountryImage and in refers to enter the following formula:

IF(SpinCountry=1,DE,UK)

Define a name with a formula

Make sure that when using a non-European version you enter the formula with a comma, otherwise use the semicolon.

This formula tells Excel that if the SpinCountry button is set to 1 it should show the German flag, otherwise the English Flag.

Select the range A3 to C14 now by going there and selecting with the arrow keys and click the camera tool once to make a snapshot of the selected area. Change to a new sheet in your spreadsheet file (e. g. Sheet 2) and click once with your cursor which should look like a little crosshair. This places the snapshot of the selected range on the new sheet.

Into the formula toolbar you should see a reference to the current image (Sheet1!$A$3:$C$14) looking like this:

The formula toolbar before

We will change this reference now to our name CountryImage so the formula toolbar looks like this:

The formula toolbar after

Go back to Sheet1 and cut the spin button by right-clicking it and paste it onto Sheet2. Now right click the image and select Format Picture. Go to the Colors and Lines tab and set both (Fill and Line) to No Fill / No Line.

One final thing to do for displaying purposes is to get rid of the grid (yep, that's a little poem Cool). Do this for each sheet by selecting all cells (CTRL+A) and select white as a fill color.

If you click the spin button now back and forth this should result in a change of the image. Voilà that's it. Hope you like it.


Administrator
Written on Wednesday, 17 February 2010 17:21 by Administrator

Viewed 3369 times so far.
Like this? Tweet it to your followers!

Rate this article

(0 votes)

Latest 'tweets' from Phil Kowalski

  • dashboard reporting http://bit.ly/eSiM68 . Dashboard Financial Reporting for Board Members Link Wednesday, 30 March 2011 16:00
  • ! http://bit.ly/fZZSOI Display hidden data in an Excel chart chart excel Link Wednesday, 30 March 2011 06:00
  • Calculate the Coefficient of Variation in Excel statistics excel http://bit.ly/h6JrOe :P Link Wednesday, 30 March 2011 01:00
  • Excel - Combine Data From 2 Different Spreadsheets With a VLookup vlookup :O http://bit.ly/gFK5YH Link Tuesday, 29 March 2011 15:40
  • Undo and Redo in Microsoft Excel 2007 windows excel :) http://bit.ly/eM064Y Link Tuesday, 29 March 2011 14:00

Comments  

 
+1 #1 Chandoo 2010-02-18 09:04
Very interesting. I can already imagine how this trick can be applied to enhance dashboards and dynamic charts.
Quote
 
 
0 #2 Administrator 2010-02-18 09:32
Quoting Chandoo:
I can already imgaine how this trick can be applied to enhance dashboards and dynamic charts.


Hi Chandoo,

thanks for your comment. Yep, I feel the same way. All these country flags, silhouettes of nations, product images etc etc.

The disadvantage of this particular approach is that you have to define an area for each and every product / nation / manager (whatever you imagine) which could make your "graphics sheet" difficult to handle.
Quote
 
 
-1 #3 Sebas 2011-02-09 00:37
Can you add exemple please ?

Thank u very much !
Quote
 

Add comment


Security code
Refresh

Sharing is caring

Facebook Twitter Digg Delicious Stumbleupon Google Bookmarks RSS Feed 

Tweet, Tweet...

Click the little blue friend to follow Phil on Twitter!

Advertisement

Create Excel dashboards quickly with Plug-N-Play reports.