Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display if

Status
Not open for further replies.

pmidwest

Programmer
Joined
Jan 9, 2002
Messages
162
Location
US
Is there a way in excel to display one picture if A1 = 1 and display another picture if A1= 2?
 
pmidwest,

I've just created a model for you. It does exactly what you've described.

I'll provide a description of what I've done, but you might prefer to email me, and I'll send you the file via return email.

First, here's the code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set Target = Range("A1")
If ActiveCell.Address <> Target.Address Then Exit Sub
If Target = 1 Then
Worksheets(&quot;Sheet1&quot;).Shapes(&quot;Picture 1&quot;).Select
Selection.Formula = &quot;p_1&quot;
Range(&quot;A1&quot;).Select
Exit Sub
ElseIf Target = 2 Then
Worksheets(&quot;Sheet1&quot;).Shapes(&quot;Picture 1&quot;).Select
Selection.Formula = &quot;p_2&quot;
Range(&quot;A1&quot;).Select
Exit Sub
End If
End Sub

Additional Steps Required:

1) Place your pictures on a separate sheet.

2) Assign the range names &quot;p_1&quot; and &quot;p_2&quot; to each of the pictures. IMPORTANT: These names need to be assigned to the cells (ranges) BEHIND each picture - NOT to the pictures themselves.

I hope this helps. Be sure to email me if you find that option easier.

Regards, ...Dale Watson dwatson@bsi.gov.mb.ca
 
Hi pmidwest,

I'm awfully curious to find out how you made out with your objective, and whether my proposed solution was suitable for your situation.

I'd really appreciate feedback.

Many thanks. :-)

...Dale Watson dwatson@bsi.gov.mb.ca
 
Dale,

When I asked the question I was trying to set up a spread sheet that would calculate a total price for a set of machines and all the raw materials that were required to do a job. My idea being I could give it to my boss and he could click around and decide what option he wanted to go with. (Saying as there were around 100 different scenarios) I figured a small compact program &quot;click here if you want to add this&quot; would make it a lot easier than handing in a 500 page report. Well the idea got shot down about half way through so I didn’t need the code after all.
But I thank you for the quick response :)
Sorry I didn’t get back to you sooner.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top