Consulting

Results 1 to 2 of 2

Thread: Insert a picture in an multiple image control with one click based on dropdown list

  1. #1

    Insert a picture in an multiple image control with one click based on dropdown list

    I am new to VBA and i don't know what should i do. I have an excel file with dropdown (combo Box). When a value in dropdown list is selected and have it inserted into a specific cell, image control (ActiveX Control) display an image with a name matching data from a cell. So far the image control (ActiveX Control) works perfectly. However, I don't know what commands are needed when there is more than one control image in my worksheet. For example, when I select a specific value from the dropdown list, the control 1 image will display the image "A" and image control 2 will display the image "B" and so on based on the respective cell references.

    I've attached a sample workbook to illustrate what I'm trying to achieve here.

    Thanks for help anyone. I really appreciate any help that you can provide!
    Attached Files Attached Files

  2. #2
    VBAX Mentor 大灰狼1976's Avatar
    Joined
    Dec 2018
    Location
    SuZhou China
    Posts
    479
    Location
    Hi jezrahman!
    Welcome to vbax forum.
    Please refer to the attachment.
    Sub combo()
    Dim NamaData, i&, pth$
    Application.ScreenUpdating = False
    NamaData = Array([f7], [i7], [l7], [o7])
    For i = 0 To 3
      pth = ActiveWorkbook.Path & "\Photo\" & NamaData(i) & ".jpg"
      If Dir(pth) = "" Then pth = ActiveWorkbook.Path & "\Photo\NA.jpg"
      Me.OLEObjects("Image" & i + 1).Object.Picture = LoadPicture(pth)
    Next i
    Application.ScreenUpdating = True
    End Sub
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •