Working with images

Russk68

Well-known Member
Joined
May 1, 2006
Messages
589
Office Version
  1. 365
Platform
  1. MacOS
Hi All
I have several pictures of equipment to the side of a sheet that is like a library. When I need to grab these pictures, I scroll over to look for it and then copy it and paste it to where I need it.

I'm looking for a shortcut that I'm guessing isn't possible. Something like: Type the name of the equipment in a cell and magically the image is pasted there.

Looking for any suggestions.

Thank you!

Russ
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
This can be done but you provided limited details.

So with this script:

Enter the Image name in any cell in column(A) and the script looks for the image name.

And will copy the shape into column(D)

Try this and see how it works and we can modify to your specific needs

You will initially need to give each image a name.
And then enter that name in column(A) for the script to run.

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  4/4/2019  1:49:38 AM  EDT
On Error GoTo M
If Target.Column = 1 Then
ActiveSheet.Shapes(Target.Value).Copy
ActiveSheet.Paste Destination:=Target.Offset(, 3)
End If
Exit Sub
M:
MsgBox "Shape not found"
End Sub
 
Upvote 0
Hi MAIT
I used the file name in column A and the image wasn't found. I also labeled it with Alt text.
How do I name the image?
 
Upvote 0
You said:
I have several pictures of equipment to the side of a sheet that is like a library.

You never explained where the name was.

I assumed you would name them yourself some how

To name a Image. Just select the image and then in the name Box above Range("A1") give it a name.
 
Upvote 0
I should have thought of that.

I wasn't expecting that there would be a way to do this.
It works great! This is so cool!

Thank you very Much!!!
 
Upvote 0
Glad I was able to help you.
Come back here to Mr. Excel next time you need additional assistance.

You will note the image is put in column D you can change that if you want.

Change offset(,3) to offset(,2 or what ever you want.

Offset(,3) means 3 columns to the right of column A

I should have thought of that.

I wasn't expecting that there would be a way to do this.
It works great! This is so cool!

Thank you very Much!!!
 
Upvote 0
I sure will!
Offset, got it!

Would you be able to prevent the message from popping up when I clear a cell?
 
Upvote 0
Try this:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  4/4/2019  8:25:41 PM  EDT
On Error GoTo M
If Target.Column = 1 Then
If Target.Value = "" Then Exit Sub
ActiveSheet.Shapes(Target.Value).Copy
ActiveSheet.Paste Destination:=Target.Offset(, 3)
End If
Exit Sub
M:
MsgBox "Shape not found"
End Sub
 
Upvote 0
It works by clearing 1 cell but if I clear more than 1 cell at the same time I will get the message.

Thank you!
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,194
Members
452,616
Latest member
intern444

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