Load Image/Picture to cell Range using image path C:\

Brass Contributor

I need help please - I search on google without a solution.

For some reason my Microsoft 365 don't have the Image function.

I have a path to an image in range Sheet1.Range("G1") e.g., C:\Users.......jpg

I want to display/show that image in Sheet2.Range("K8")

 

or if I can display/load the image from the userform directly to Sheet2.Range("K8") it will also help.

 

Thank you

7 Replies

@LizeMarie 

 You can use code like this:

    Dim rng As Range
    Set rng = Sheet2.Range("K8")
    Sheet2.Activate
    rng.Select
    With Sheet2.Pictures.Insert(Sheet1.Range("G1").Value)
        .Width = rng.Width
        .Height = rng.Height
    End With
Thank you so much Hans it works! Yeah!
The range are merged cells, how can I change the width and height accordingly Height must be 30.03 cm and width 3.24 cm
Thank you again Hans - I struggled with this for more than 2 days' :) Highly appreciate your reply

@LizeMarie 

That would be

    Dim rng As Range
    Set rng = Sheet2.Range("K8")
    Sheet2.Activate
    rng.Select
    With Sheet2.Pictures.Insert(Sheet1.Range("G1").Value)
        .Width = Application.CentimetersToPoints(3.24)
        .Height = Application.CentimetersToPoints(30.03)
    End With
I made a mistake with the Hight, but I can change it myself.
OMW Hans, you don't know how much I appreciate this. Thank you so much! Be blessed and have a wonderful day
Hans, I came across another challenge.... hope I can return to you for help again. When the path change, I need to delete the previous image/picture to change it with the new image. How can I do that?

@LizeMarie 

For example:

    Dim rng As Range
    Dim pic As Picture
    Set rng = Sheet2.Range("K8")
    ' Delete Picture from K8
    For Each pic In Sheet2.Pictures
        If pic.TopLeftCell.Address = rng.Address Then
            pic.Delete
            Exit For
        End If
    Next pic
    ' Insert new picture
    Sheet2.Activate
    rng.Select
    With Sheet2.Pictures.Insert(Sheet1.Range("G1").Value)
        .Width = Application.CentimetersToPoints(3.24)
        .Height = Application.CentimetersToPoints(30.03)
    End With
Perfect - You are absolutely amazing.
Thank you for sharing your knowledge with me. Again, I highly appreciate it.