1

I am working with Excel 2013.

Someone may be know how to show the picture instead of URL. I have the URL list and by VLOOKUP formula I want to display picture.

Through VLOOKUP I find the URL then I use HYPERLINK .

So when I type a new item code in the search field I need the picture to be shown.

I tried:

Sub Test()
    Dim Pic As Picture
    Application.ScreenUpdating = False
    With ActiveSheet.Range("k19")
        Set Pic = .Parent.Pictures.Insert(.Value)
        With .Offset(, -1)
            Pic.Top = .Top
            Pic.Left = .Left
            Pic.Height = .Height
            Pic.Width = .Width
        End With
    End With
    Application.ScreenUpdating = True
End Sub

However, every time I type a new code the picture does not refresh.

I have to run the module again.

And also maybe it is some extension to the script that could adjust the display size of the pic?

  • what cell is your code being typed into ? – PeterH Jan 24 '18 at 14:18
1

You can use a work sheet change trigger.

Try the below code in place of your current code.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then
Dim Pic As Picture
    Application.ScreenUpdating = False
    With ActiveSheet.Range("k19")
        Set Pic = .Parent.Pictures.Insert(.Value)
        With .Offset(, -1)
            Pic.Top = .Top
            Pic.Left = .Left
            Pic.Height = .Height
            Pic.Width = .Width
        End With
    End With
    Application.ScreenUpdating = True
End If
End Sub

Change A1 to the CELL where you enter your 'New Code'

  • thanks a lot for your suggestion, but i guess i am doing something wrong. when i put this code and try to activate by F5 macro is asking me to choose the name, but no possibilities is displayed to be chosen – Evei Baltic Jan 30 '18 at 13:51
  • @EveiBaltic this will activate, when you change the CELL A1, link this to the cell where your new code goes – PeterH Jan 30 '18 at 13:54
  • but you mean the primary code i will need to enter manually? becuse i tried this it still ask me to put the name. "Private Sub" is correct? and "End sub"? it looks like the program do not react to the code at all – Evei Baltic Jan 30 '18 at 14:51
  • @EveiBaltic Just copy the code into a new module, change cell A1, and it should work – PeterH Jan 30 '18 at 14:52
  • thank you very much for your help, but something is wrong this new modul never show itself in the modul list – Evei Baltic Jan 30 '18 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.