PDA

View Full Version : Change picture based on cell value



mike0123m
05-02-2008, 10:24 AM
I have a combobox that is populated using the listfillrange. I would like the picture shown in an image control on the worksheet to change based on the value in the combobox combined with the value in cell R27 but I can't seem to get my code to work. Here is what I have:


Private Sub ComboBox4_Change()

Select Case Me.ComboBox4.Value & Range("r27").Value
Case "gable0-7"
Me.Image2.Picture = LoadPicture("x:/excel programs/fbc tile/gable0-7.bmp")
Case "gable7-27"
Me.Image2.Picture = LoadPicture("x:/excel programs/fbc tile/gable7-27.bmp")
Case "gable27-45"
Me.Image2.Picture = LoadPicture("x:/excel programs/fbc tile/gable27-45.bmp")
Case "hip7-27"
Me.Image2.Picture = LoadPicture("x:/excel programs/fbc tile/hip7-27.bmp.bmp")
Case "monoslope3-10"
Me.Image2.Picture = LoadPicture("x:/excel programs/fbc tile/mono3-10.bmp")
Case "monoslope10-30"
Me.Image2.Picture = LoadPicture("x:/excel programs/fbc tile/mono10-30.bmp")
End Select
End Sub

Simon Lloyd
05-02-2008, 10:51 AM
How is the Case item split up? e.g "gable0-7" is it "gable" & "0-7", "gable0" & "-7"...etc? are the digits stored as text or numbers? are they part of or a result of a formula?

OBP
05-03-2008, 07:13 AM
Mike, I already have an Excel workbook doing this and the "key" to success for me was to include the "Paths" to the Photographs in the Fill range of the Combo box, so by selecting the Name you also select the path. So you don't need the case statement at all.