www.office.com/setup: Dave has a large database that he saves in an Excel workbook. It consists of samples of materials and uses the VLOOKUP function to generate various forms and reports. Dave wants to include a bitmap image in the form that changes according to one of the variables. For example, if the form describes an apple, Dave wants an image of an apple to appear; if a pear is described, a pear should appear; and so.
This is certainly a challenging task, but it is one that can be done surprisingly without macros. The steps are involved, but not so difficult to do once you do it:
In a new worksheet, select a cell (such as cell B4).
Enter the name “apple” in the Name box. This defines the name “apple” to refer to cell B4.
With cell B4 still selected, choose Insert | Image | From the file. Select the image of the apple and insert it.
Expand the width and height of cell B4 so that the image of the apple is completely inside the cell.
Repeat steps 1 to 4 for each of your other images, place each image in a different cell and name them according to the content of the image. (For the sake of this example, I will assume that “pear” is cell D4 and “orange” is cell F4).
In the worksheet that will contain your form, create a formula that will contain the names of the fruit, like the following formula, which shows “apple”, “pear” or “orange”, according to the value in cell G1. (It is important that the formula refer to the names exactly as you defined them in step 2 for each fruit photograph.) For the sake of this example, I will assume that you entered this formula in cell A1 of Sheet1).
- Choose Name from the Insert menu, then choose Define. Excel displays the Define Name dialog box. (See Figure 1.)
Figure 1. The Define Name dialog box.
- Replace the contents of the Names In Workbook box with the word “Picture”.
- Replace the contents of the Refers To box with the following formula:
- Click on the OK button. Now you have defined the name “Image” to contain the formula entered in step 9.
- On the worksheet that will contain your form, select the cell where you want the dynamic image to appear.
- Choose Insert | Image | From the file. Select and insert an image (it does not matter which one).
- Make sure that the image you inserted in step 12 is selected.
- In the formula bar, enter the formula = Image. (This is the name you defined in steps 7 through 10.)
- The image must change to reflect any fruit that has a name in cell A1.
- Now, every time you change the name of the fruit in cell A1 (which in turn is based on the value of cell G1), the image will change.ExcelTips is your profitable training source for Microsoft Excel. This tip (3128) applies to Microsoft Excel 97, 2000, 2002 and 2003. You can find a version of this tip for the Excel ribbon interface (Excel 2007 and later) here: Viewing images based on a result.Original publication: https://excel.tips.net/T003128_Displaying_Images_based_on_a_Result.html