Forum Discussion
EXCEL - IMAGE ACTIVE CELL
Failed. kkk
It work with the folder the code you send to me :), but is not the way i wish.
Thank you for the advice of the file size, but is just some images.
I have that project on my pc, its beautiful.
But i wish to send to someone and that person open the file and see the file just like me.
I made a lot of research and i could not find anything like that.
Most videos on youtube or sites only teach with Folders, never on the Worksheet.
I could you vlookup, but is not dynamic.
I could use function Image, but is not dynamic.
I Could use an Object, but is not dynamic.
After you see the video, you will agree with me
https://www.youtube.com/watch?v=7OJI2uTc2II&t=71s&pp=ygUWZXhjZWwgaW1hZ2VtIGFvIGNsaWNhcg%3D%3D
It seems you are looking for a solution to dynamically display images in a shape based on the active cell's value, and you want the images to be stored in another worksheet. Unfortunately, Excel does not have a built-in feature to dynamically display images (so far I know) in this way without relying on external files or folders.
However, you can create a workaround using Excel's Picture function and named ranges. Here's a general approach:
- Create a Named Range for Each Image:
- In the worksheet where the images are stored, create a named range for each image. You can do this by selecting the cell with the image, going to the "Formulas" tab, and choosing "Define Name."
- Modify the VBA Code:
- Adjust the VBA code to use the Picture function and reference the named ranges dynamically. Replace the existing VBA code with the following:
Vba code (is untested):
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
' Delete the existing image shape
Me.Shapes.Range(Array("FOTO")).Delete
If Target.Row > 1 And Target.Value <> "" Then
Dim imgName As String
Dim imgShape As Shape
' Get the name of the image range based on the target value
imgName = "Image_" & Target.Value
' Insert the image into the worksheet
Set imgShape = Me.Pictures.Insert(ThisWorkbook.Names(imgName).RefersToRange.ImageBytes)
' Customize the image shape
With imgShape
.Name = "FOTO"
.Left = Target.Left + Target.Width
.Top = Target.Top
.ShapeRange.LockAspectRatio = MsoTriState.msoCTrue
.ShapeRange.Width = 100
.ShapeRange.Height = 100
.Shadow.Type = msoShadow21 ' Add shadow
End With
End If
End Sub
3. Create Named Ranges for Images:
- Ensure that each image in the image worksheet has a unique name (e.g., Image_Apple, Image_Orange).
With this approach, each image is treated as a named range, and the VBA code dynamically inserts the image based on the active cell's value.
Please note that this is a simplified solution, and you may need to adapt it based on your specific requirements and the structure of your workbook. Additionally, ensure that the image names in the image worksheet match the expected names in the VBA code.
If this doesn't help you, please provide more detailed information. Excel version, operating system (Mac, Win., Server, etc.), storage medium (Sharepoint, OneDrive, etc.), file extension (xlsx, xlsm, etc.). They wrote this, The images it will be in another worksheet. Do you mean worksheet or workbook? More detailed information will help to suggest a more precise solution.
- WLLIANDec 28, 2023Brass Contributor
NikolinoDEHi. I try, but i must doing a lot of things wrong. kkkk
I share in One drive, link below if helps 🙂
https://onedrive.live.com/edit?id=36169DA5A4F12415!152127&resid=36169DA5A4F12415!152127&ithint=file%2cxlsx&authkey=!ADyYNU11qsRDfdA&wdo=2&cid=36169da5a4f12415
Windows 10 = 64
Microsoft 365
.xlsm