Changing picture based on cell value

  • By changing text in cell the image has to paste from file.I used below Code it's working fine But once you delete the images from file then the image from excel disappears and showing error. Is it any option instead of Insert can we auto paste in excel.


  • Try this code, it uses a fixed range but it would be easy to amend the code to allow the user to select a range


  • rory

    Changed the title of the thread from “By changing text in cell the image has to match from file.I used below Code but it's working fine But once you delete the images from file then the image from excel disappears and showing error. Is it any option instead of Insert can we auto paste in exce” to “Changing picture based on cell value”.
  • Hi...Thank for Code.

    I used above code but its help to only copy paste.

    Actually Buy using below code based on cell [A:A] value i can able to auto call image from file and inserting in next cell in excel.

    ex: If I Type 0007 in cell A1 then micro check for image in file, name 0007.JPG and it Inserts it in Cell B1.

    But Problem is, it's Dynamic image , Once i delete photo from file/Folder or if i move a Excel in another location the Cell B1 image will Disapperse with box in Cell B1 as "picture cannot be displayed unlinked or deleted "

    Any solution Instead of insert can we insert as copy , Paste as static image in excel , so i can move the excel any folder or location.

  • Hi.

    need solution on below code .

    ex: If i type xyz in cell "A" the code has to call xyz image from folder and paste in cell "B"

    I am using below code but once I move excel or delete photos form folder showing error.The linked image cannot be displayed. the file may have been moved, renamed, or deleted verify that the link points the correct file and location"

    Can we modify below code by Shapes.AddPicture Or any other static image code ?


  • I have few photos with Names and saved in one folder. also i have excel where Photos Names are in Cell"A" and i want to map these photos in Cell "B" (copy paste). i can able to do it by above code but once i move excel or photos it giving error "The linked image cannot be displayed. the file may have been moved, renamed, or deleted verify that the link points the correct file and location"

    so if there is any other code to paste photos in cell"B" based on Cell "A" Values ?

  • yes.....you provided code.

    but that is different. Where I am adding photos from user form to excel.


    But this thread is different..in this, I am calling images from folder to excel based on cell "A" value..my code is working but I am not able to add a static image/shapes.addpicture.

  • Try this



  • Same error is shown once i delete image from folder "The linked image cannot be displayed. the file may have been moved, renamed, or deleted verify that the link points the correct file and location" and also it is not adjusting with Cell Size. I am attaching Excel file provide code.


    Thank you.

  • Otherwise any code to break a link of linked image in excel. (getting error if i move/copy excel from one folder to another and when i delete photos from folder, image place it is showing above error ) ?