VBA / MACRO for inserting picture based on the contents of a cell changes

Jzfbkr

New Member
Joined
Aug 4, 2014
Messages
29
Hi Im wondering if anyone can help me with something.

Im looking to insert a picture into my excel sheet based on the contents of an input cell.

so when name in the input cell changes so does the logo/picture.

any help would be much appreciated.

Im currently using the Mr.Excel Picture lookup technique but im not entirely happy with it.

Thanks
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi JzFbkr

You can use shape for this and insert image in it. And code on worksheet change.

Code:
Sheets("Sheet1").Shapes("ShapeName").Fill.UserPicture Path & "NoImage.jpg"
 
Upvote 0
First of all thank you for getting back to me.

Im not too familiar with VBA can you tell me which parts of that code i need to change.

Eg in the input cell?
 
Upvote 0
The Sheet I would like the image to be displayed on is called PRINT OUT REPORT
The Shape is called 'Al Ahli' located on SHEET1
The image within the shape is call AL AHLI and is located in C:\Users\admin\Desktop\Presentation\Logos\Club
The input is cell F4 on the PRINT OUT REPORT sheet


Sheets("Sheet1").Shapes("ShapeName").Fill.UserPicture Path & "NoImage.jpg"
 
Last edited:
Upvote 0
Put a shape on your PRINT OUT REPORT sheet and rename it , Give same name in code too.

and use below code and paste on the sheet code .. just press Alt + F11 then put under the sheet PRINT OUT REPORT editor

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intercept(Target, Range("F4")) Is Nothing Then
    
    If Range("F4").Value = "XXXX" Then
        Sheets("PRINT OUT REPORT").Shapes("ShapeName").Fill.UserPicture "C:\Users\admin\Desktop\Presentation\Logos\Club\" & "XXX.jpg"
    Else
        Sheets("PRINT OUT REPORT").Shapes("ShapeName").Fill.UserPicture "C:\Users\admin\Desktop\Presentation\Logos\Club\" & "YYYY.jpg"
    End If
    
End If
End Sub
 
Upvote 0
Will it only work with .jpg images? Im using .png

Also I've input a shape on the the PRINT OUT REPORT sheet and named it "ShapeName" but nothing is happening?

Do I have to replicate this section for each logo?:


If Range("F4").Value = "TEAM A" Then Sheets("PRINT OUT REPORT").Shapes("ShapeName").Fill.UserPicture "C:\Users\admin\Desktop\Presentation\Logos\Club Logos\" & "TEAM A.png"
If Range("F4").Value = "TEAM B" Then Sheets("PRINT OUT REPORT").Shapes("ShapeName").Fill.UserPicture "C:\Users\admin\Desktop\Presentation\Logos\Club Logos\" & "TEAM B.png"</pre></pre>
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top