MACRO to insert image with respect to drop-down list

Asked

Viewed 119 times

1

Good morning, everyone,

I’m having a doubt I don’t know if it’s frivolous or not:

I have a field (the large rectangle) of which I want to insert an image inside it, according to the selected drop-down list.

For example: When I select from the drop-down list (L11) "Ceu2", I want the "Ceu2" image located in Q6 to appear in the rectangle. When selecting Heaven, the same thing, but for the image in Q5.

However, in the same rectangle, when the person selects through cell L3 the 2nd Drop-down List, with the options, stop appearing the images of the sky and appear which one he or she chooses, be it the "oculos" or the "train".

That would be great. I was trying to do this using the INDEX and CORRESP functions, but did not reach the character limit of the CORRESP kkk function

If anyone can help you out. then I want to pass X time without a new option change from the drop-down list, the image that appeared in the rectangle was that of the "theme" contained in Q9

If I get confused I’ll explain again, but at first it was just that. Thank you to anyone who can help =)

inserir a descrição da imagem aqui

  • 1

    Related: https://answall.com/questions/151434/addir-foto-em-planilha-excel-partir-de-pasta-local

2 answers

2

Solution without macro

inserir a descrição da imagem aqui

Within what you’ve already built what you need to do is create a [Name Defined] formula and then link to the camera. Follow the steps:

inserir a descrição da imagem aqui

  1. Log in to [Name Manager]
  2. In name manager create a new item
  3. Footsteps:
NAME> cImage
Scope> Workbook
Comment> [branco]
refers to: > =OFFSET($Q$4;MATCH($L$11;$P:$P;0)-1;0)
Botão {OK}

Adc. a camera component, to activate:

  1. File > Options
  2. Follow steps 1 to 5. Option 6 should open for you.

inserir a descrição da imagem aqui

From here just select the cell that is the image. In your case at $Q$5. and click on the camera. Note that the image will respect the size of the range/cell. Then try to add. images of the size you want to use and resize the cell and image of the same size.

inserir a descrição da imagem aqui

Now when selecting the camera that is nothing more than a dotted square, change in the formula dash by =cImage

0

You can use the cbxListaSuspensa_change event so that each new change in your list a macro is excommunicated and from this execution the image is changed to the image path that is contained in the drop-down list.

Sub cbxListaSuspensa_change()
Dim caminho As String
'Valor que está na lista suspensa
caminho = cbxListaSuspensa.Value
'Setar a imagem que deve ser colocada no espaço
sheet1.Image1.Picture = LoadPicture(caminho)
End Sub

Cenário criado para o código

  • Hello Vinícios, I don’t know if I understood very well. But in your example the image would appear as the selection of the dropdown list, right? But I have + of 1 drop-down list, and I want as I go selecting the options from the list, the image that will appear on the board will change as well

  • Just use a second event as cbxListaSuspensa2_change. This way, when the second has its value changed the macro will be executed.

  • I’m not really managing to even execute your example, but I’ll keep trying

  • The way would not be something like: caminho = ThisWorkbooh.Path & cbxListaSuspensa.Value or caminho = "C:/Fotos" & cbxListaSuspensa.Value

Browser other questions tagged

You are not signed in. Login or sign up in order to post.