Conditional Picture?

Does anybody knows how to insert one picture that changes without use
intervention everytime the result of another cell changes?
eg.: If the cell A1="Alex" the cell A2=Picture of Alex. Then if 
change the cell A1 to "Mike" the cell A2 displays the picture of Mike

--
Message posted from http://www.ExcelForum.com

0
12/26/2003 1:28:59 PM
excel.misc 78881 articles. 5 followers. Follow

2 Replies
413 Views

Similar Articles

[PageSpeed] 32

Hi Alex

This macro example from this group a long time ago you can use.
The jpg files must have the same names as the number you type in cell "a1"
Change the path to the files in the code.

Place the code in the Sheet module

Right click on a sheet tab and choose view code
Paste the code there
Alt-Q to go back to Excel


Private Sub Worksheet_Change(ByVal Target As Range)

    Dim rng As Range
    Dim rngProducts As Range
    Dim pic As Picture, shp As Shape
    Dim szInvalids As String

    On Error Resume Next
    'Only insert the picture if it's in the area where they type the Product Names
    'Change "a1" to a range of cells where they'll be typing in Product numbers
    Set rngProducts = Intersect(Me.Range("a1"), Target)
    On Error GoTo 0

    If Not rngProducts Is Nothing Then  'They entered a product number
        'Loop through each cell they entered in
        '   in case they copied several product numbers into several cells
        For Each rng In rngProducts
            'Remove the exisitng picture (shape) from the cell to the right
            For Each shp In Me.Shapes
                If shp.TopLeftCell.Address = rng.Offset(0, 1).Address _
                Then shp.Delete
            Next shp
            'Insert the picture
            On Error Resume Next
            Set pic = ActiveSheet.Pictures.Insert("C:\Documents and Settings\Ron\MyFiles\" _
            & rng.Text & ".jpg")
            On Error GoTo 0
            If Not pic Is Nothing Then  'The picture exists
                With pic
                    .Height = rng.Offset(0, 1).Height
                    .Width = rng.Offset(0, 1).Width
                    .Left = rng.Offset(0, 1).Left
                    .Top = rng.Offset(0, 1).Top
                End With
            Else    'Invalid entry, add it to the list of invalids
                szInvalids = szInvalids & rng.Address & ": " & rng.Text & vbLf
            End If
        Next rng

        'Show them the invalid entries if there wer any
        If Len(szInvalids) Then
            szInvalids = "The following were either invalid product entries or " & vbLf _
            & "the product's image could not be found:" & vbLf & vbLf & szInvalids
            MsgBox szInvalids, vbExclamation
        End If
    End If
End Sub


-- 
Regards Ron de Bruin
(Win XP Pro SP-1  XL2000-2003)
www.rondebruin.nl



"AlexCdeC" <AlexCdeC.z1qjy@excelforum-nospam.com> wrote in message news:AlexCdeC.z1qjy@excelforum-nospam.com...
> Does anybody knows how to insert one picture that changes without user
> intervention everytime the result of another cell changes?
> eg.: If the cell A1="Alex" the cell A2=Picture of Alex. Then if I
> change the cell A1 to "Mike" the cell A2 displays the picture of Mike.
>
>
> ---
> Message posted from http://www.ExcelForum.com/
>


0
rondebruin (3789)
12/26/2003 3:09:40 PM
One way:

Add all the pictures you want to the worksheet.  Name them Pict_Alex, Pict_Mike,
Pict_namehere.

Put them all where you want them to show up (probably directly on top of each
other????).

Then right click on the worksheet tab that holds the pictures and select view
code.  Paste this in:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim myPict As Picture

    If Target.Cells.Count > 1 Then Exit Sub
    If Intersect(Target, Me.Range("A1")) Is Nothing Then Exit Sub

    For Each myPict In Me.Pictures
        myPict.Visible = CBool(StrComp(myPict.Name, _
                            "pict_" & Target.Value, vbTextCompare) = 0)
    Next myPict

End Sub

When you type in the name in A1, this worksheet event will fire and the code
will hide all the pictures whose name doesn't match pict_valueinA1.

A tip for renaming the pictures.  Select each and type the new name in the
namebox--to the left of the formula bar.  Remember to hit enter when you're done
typing.



AlexCdeC wrote:
> 
> Does anybody knows how to insert one picture that changes without user
> intervention everytime the result of another cell changes?
> eg.: If the cell A1="Alex" the cell A2=Picture of Alex. Then if I
> change the cell A1 to "Mike" the cell A2 displays the picture of Mike.
> 
> ---
> Message posted from http://www.ExcelForum.com/

-- 

Dave Peterson
ec35720@msn.com
0
ec35720 (10082)
12/26/2003 3:21:24 PM
Reply:

Similar Artilces:

Today Conditional Format
I have a column which calculated a date based on 3 working days from a date input into a diff column. What I want to do I have the calculated date appear bold if that date has passed based on the current date. For example if I input 01/08/11 the next column calculates 04/08/11 (3 working days). I want the caluclated date to appear bold when I open the spreadsheet on the 05/08/11 ro show the calculated date has passed. I can use conditional formatting but can't get the syntax right Regards Andy Win XP Pro Office 2010 Andy Roberts presented the following explanation : > I ha...

Two Condition Vlookup?
I am currently trying to create a function that searches through an array for two exact column values which allows me to retrieve a third column value. For example: Type of Fruit Date Packaged Amount of Fruit Apples June 100 Oranges June 50 Apples July 75 Grapes July 50 In this example, I would be looking to retrieve the Amount of Fruit (Apples) that was packaged in July. I would be putt...

picture wont print correctly
Hello, I am trying to print a company logo in Publisher, its brown and black. It looks fine on the document and in print preview but when I print it only the brown portions of the logo are printed and they come out light blue. Please help ! MelissaYH <MelissaYH@discussions.microsoft.com> was very recently heard to utter: > Hello, I am trying to print a company logo in Publisher, its brown > and black. It looks fine on the document and in print preview but > when I print it only the brown portions of the logo are printed and > they come out light blue. Have you checked yo...

Query condition by date range
I'm trying to create a query to base a report from. I need it to return records within a date range that needs to be specified, as in specifying the beginning date and having the current date as the end date. A field is included in the query that has listed dates in the format mm/dd/yyyy. How would I write the criteria? I have part of it ready - [Please enter starting date:] . I know that's how you get the little question window. On Tue, 4 Dec 2007 14:51:00 -0800, silva wrote: > I'm trying to create a query to base a report from. I need it to return > records within a...

Need help with conditional formula (Excel 97)
Can anyone give me the correct syntax for the following formula: if A1 is blank, and B1 is more than zero, then display B1, otherwise display nothing (blank cell) Thank you JD =IF(AND(A1="",B1>0),B1,"") Success! -- met vriendelijke groetjes "Jake D" <JakeD@djhtend.com> schreef in bericht news:crkto4lv30u7uujv27ek8okr0us5t9oj10@4ax.com... > Can anyone give me the correct syntax for the following formula: > > if A1 is blank, and B1 is more than zero, then display B1, otherwise > display nothing (blank cell) > > Thank you > > ...

Conditional formatting if condition of an if statement is true and a string value is displayed
Dear Experts: I got a nested 'IF'-Formula in an excel cell that returns nothing if the condition is false. I would like to conditionally format this cell with grey shading if the condition is true and a string value is displayed. How can this be achieved using excel conditional formating functionality ? Help is much appreciated. Thank you very much in advance. Regards, Andreas Let's say your doing this conditional formatting in cell K17. In conditional formatting (xl2003) choose the FormulaIs: option and enter: =$K$17<>"" choose your formatt...

Conditional Field in Queries
Is there a way to make a field in a query conditional so that it only displays the value if the value is equal to something specifically set? Thanks. Nick Nick.Korynski@gmail.com wrote: > Is there a way to make a field in a query conditional so that it only > displays the value if the value is equal to something specifically > set? Thanks. > > Nick Explain "the value is equal to something specifically set". -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com ...

How do i use Conditional formatting for 3+ conditions ?
I have a text box in a report which highlights in colour current members in a list of past and present member names. I have six types of current members that I want to highlight, but with conditional formatting I can only use 3 conditions in the members [Type] field. I have tried [Type]="Full member" Or "Life member" but the "Or" doesn't work ! Is there a way to do this ? thanks .. Roger CF is limited to 3 contitions, but you can use OR in those expressions. If you set Condition1 to Expression, you can use: ([Type] = "Full member") Or (...

Help with Conditional formatting with Dates
Hi there, I have a spreadsheet in which I have to monitor various dates which are in different columns (i.e. (1) Date Tender Released, (2) Date Company Selected, (3) Date Draft Contract Forwarded, (4) Date Contract Signed etc...). Would if be possible to Conditional Format and have diffirent ROWs highlighted for each individual Contracts (I have 300 running contracts running) every time a date is filled in these different columns: Initial Step (1) = Yellow (Call for Tender released) Step (2) = Blue (Company Selected) Step (3) = Brown (Contract under Process) Step (4) = Green (Contract Si...

Conditional null value
Wondering if anyone can suggest a way to simplify the following code, which I’m using in the OnFormat event of a report. If Not IsNull(DLookup("[ICD2]", "EntryICDs", "[EntryNum] = " & Me! [PtAcct#])) Then Me![Field192] = Replace(DLookup("[ICD2]", "EntryICDs", "[EntryNum] = " & Me![PtAcct#]), ".", " ") End If If Not IsNull(DLookup("[ICD3]", "EntryICDs", "[EntryNum] = " & Me! [PtAcct#])) Then Me![Field194] = Replace(DLookup("[ICD...

Help
Forgive me if "Conditional Sums" is not the accurate word for what I am trying to accomplish... I'm at a loss for what to call this situation. What I have is a spreadsheet totaling attendance figures for classes taught by two people (Dave and Cary). Column A lists their name, and next to it in Column B is the number of people who attended that class. What I need is a formula that will look at the sheet and report in a given cell the total for attendance for each person. I can work basic formulas like SUM, but that will give the total for the entire column, when what I n...

XML Receipt and Conditions
I wanted to make a small adjustment to the receipt when a certain condition is met. If a particular word (eg. family) is typed into the comment on an item I wanted something slightly different to happen to the receipt I've just about got it, just stuck on the condition tag <IF> <CONDITION>len(Entry.Comment)</CONDITION> <THEN> I can get it using len but this makes it happen for any word, is there anyway I can make it so that it is more specific ie Entry.Comment contains '%family%' try <IF> <CONDITION>Entry.Comment like '%family%'&...

conditionally restricting values in excel
Hello, I want to restrict values in a particular column based on the value in other column. For eg. if column A has value int then column B should be restricted to values 1,2,3,4,5 if column A has value bool then column B should be restricted to values true and false. if column A has value string I dont want any validation to be done and the list box should not appear. Is this possible..... How do I achieve this ? Can I use macros to do this? How? Thanks Hi as a starting point: http://www.contextures.com/xlDataVal02.html >-----Original Message----- >Hello, >I want to restrict ...

Picture in message appears bigger than original
I'm using Outlook 2003. I have this problem with adding pictures in messages. When ever I add a picture in a message(not as attachment), the picture looks much bigger than it actually is. The funny thing is that, when I check the size of the image in the message it shows to be the same size as what it should be, say 1 inch height and width. But looking at it in the message it looks like it's about 30% bigger. I don't want to adjust the pic everytime I send a message with a pic pasted in it. I'm using winxp pro as well. Any suggestions? Thanks for helping. Pri...

Conditional formating condition..?
Hi All I have 2 CF conditions associated with a cell (C14), one of which is: Formula is =OR($C$4="Fred SOMEBODY",C14<>"10:30:00") What happens when this is true isn't important/relevant. The value in the cell appears as 10:30 (formatted as custom/hh:mm) but the value in the 'formula window' is actually 10:30:00. This type of condition works fine when the cell contains a simple number (or text) but I can't get it to work for either times or dates. I have tried it with and without the inverted commas (around the time value) and have tried using 10:30 ...

How to display EMF in picture control?
The picture control has type "Enhanced Metafile" but how do I load the picture into it? Does anyone know? A picture control is a CStatic. This might be what you want: http://www.codeproject.com/staticctrl/emfctrl.asp -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com <mdnightman@gmail.com> wrote in message news:1146843133.038689.53980@g10g2000cwb.googlegroups.com... > The picture control has type "Enhanced Metafile" but how do I load the > picture into it? > > Does anyone know? > ...

Condition Formatting!
How do I make a row of cell (shading) that change to red color when the word "trial" or "limit" is entered? i.e cell 3f contain the word "trial". From the column of trial to the 1st column, the entire row 3a to 3f will be red? a b c d e f 1 2 3 Trial 4 5 6 Here's some VBA you could paste into the codebehind page for that sheet: Private Sub Worksheet_Change(ByVal Target As Range) If UCase(Target.Value) = "TRIAL" Or UCase(Target.Value) = "LIMIT" T...

chart conditional formatting
I have a line chart with 3 lines, red, blue and green. Is there any way I can conditionally format some, but not all, points on the red line to colour white - ie make them invisible. I have looked at Jon Peltier's site - he addresses conditional formatting - but cannot see a solution there. Thanks in advance to all who try to help. -- bob777 ------------------------------------------------------------------------ bob777's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=28504 View this thread: http://www.excelforum.com/showthread.php?threadid=488635 Hi, Ha...

Publisher, pictures in document keep disappearing when printing
The pictures are in the document, then when it is printed they don't print. Then the pictures disappear from the document altogether. Manually put the pictures back into the document, then printed OK, then 2 hours later the same problem over again, pictures not printing then disappearing from the document. Read the third FAQ here Q: Why can I not see images/shapes/lines when editing my publication? http://ed.mvps.org/Static.aspx?=Publisher/FAQs -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Miles" <Miles@di...

How to put different picture on each nametag?
I want to do mail merge to create nametags on business card stock, but I want a different picture on each one next to the name. How would I do that? What version Publisher? You can do a catalog merge if you have Publisher's 03 or 07. Setup your page with .75 side margins, .5 top & bottom margins, two columns, 5 rows, zero spacing. Adjust the catalog block to fit the 3.5 x 2 space you created. In step 5 create a new publication. Help here on how to setup your data http://office.microsoft.com/en-us/publisher/CH062524751033.aspx -- Mary Sauer MSFT MVP http://office.microsoft.com/ ...

Conditional Picture?
Does anybody knows how to insert one picture that changes without use intervention everytime the result of another cell changes? eg.: If the cell A1="Alex" the cell A2=Picture of Alex. Then if change the cell A1 to "Mike" the cell A2 displays the picture of Mike -- Message posted from http://www.ExcelForum.com Hi Alex This macro example from this group a long time ago you can use. The jpg files must have the same names as the number you type in cell "a1" Change the path to the files in the code. Place the code in the Sheet module Right click on a sheet tab ...

How do I make pictures saveable by visitors to the site?
In "front page" a visitor can right click and select the option to save the picture. Is this option available in Publisher and if so, how do I create or grant this option to the visitors to my web site. If I remember correctly this was taken out of the Publisher created web pages. If your visitors look in their temporary folder, the image will be there. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Malcolm" <Malcolm@discussions.microsoft.com> wrote in message news:44214A2F-537D-4093-B543-71476226FEE3@...

Conditional Formatting for 4 conditions
How can I set up conditional formatting for the following: >3.5 = red 2.5 - 3.49 = yellow 2 - 2.49 = green <2 = blue Thanks, Steve Set all the cells to one of the colours that apply the 3 conditions to them via CF, effectively 4 colours. -- HTH Bob "Steve" <Steve@discussions.microsoft.com> wrote in message news:3E34D7F5-545C-4177-83C7-93A735398F42@microsoft.com... > How can I set up conditional formatting for the following: > >>3.5 = red > 2.5 - 3.49 = yellow > 2 - 2.49 = green > <2 = blue > > Thanks, &...

About stopping container to resize on some condition
Hi I am new in this group. I am using Docking window in my application. When I dock more than one window to each other. I read that it creates container for all that panes. Now when I am docking 3-4 windows horizontally , It create one vertical resizing bar. I want that bar remove and also remove the facility of resizing on some condition. but window should not be undocked. It must be in same position and also I must able to resizing horizontally. Just I want to turn off the vertical resizing as well as remove vertical bar or make it thinner. If anyone has any solution. Please ma...

Conditional, Conditional Formatting
Two questions, both have to do with semi-complex (at least for me) conditional formatting. 1) I have two conditional formatting "formulas" on column B. Depending on the corresponding row in column I, I want the conditional formatting on or off. If I3 = 0, then don't allow conditional formatting for b3. 2) I want cells from column A to be "strikethrough" if the corresponding cell in column I equals zero. Is there any semi easy (from a data entry standpoint) way for this to be accomplished? Thanks, John One way: Say your current CF for column B is to...