Working with images

Russk68

Active Member
Joined
May 1, 2006
Messages
465
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
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,286
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
 

Russk68

Active Member
Joined
May 1, 2006
Messages
465
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?
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,286
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.
 

Russk68

Active Member
Joined
May 1, 2006
Messages
465
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!!!
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,286
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!!!
 

Russk68

Active Member
Joined
May 1, 2006
Messages
465
I sure will!
Offset, got it!

Would you be able to prevent the message from popping up when I clear a cell?
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,286
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
 

Russk68

Active Member
Joined
May 1, 2006
Messages
465
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!
 

Forum statistics

Threads
1,082,300
Messages
5,364,381
Members
400,796
Latest member
vrcdesktop

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top