Changing Thumbnail Pictures in a UserForm
Sub tester9()
Dim i, j
For i = 0 To 2
For j = 0 To 4
Debug.Print i, j, i * 5 + j + 1
Next: Next
End Sub
Generates the number 1 to 15 ( or remove the +1 and get 0 to 14).
You can use this type formula to identify which file to load. If you name
your pictures
File1.jpg
file2 .jpg
then you just do
i = Range("B17").Value
j = Range("E12").Value
Image1.Picture - LoadPicture("File" & i * 5 + j + 1 & ".wmf")
or put your file names in a 1 based array and use the formula to give you
the array index.
--
Regards,
Tom Ogilvy
pcsis wrote in message
news:UqHJb.70081$6b2.15451@edtnps84...
Hi All,
I've got a UserForm that includes a thumbnail image. What I would like to
do
is have the image change based upon the values in two cell of the
worksheet.
When I show the UserForm it should display the image that corresponds to
the
particular cell value combination.
e.g.
When B17 and E12 are both 0 then when the UserForm is shown the image1 is
displayed.
When B17 = 0 and E12 = 1 then the UserForm displays image2 and so on.
There are 15 possible conditions as B17 will only ever range from 0 to 2
and
E12 from 0 to 4.
The 15 image files (wmf) metafiles are located in the same folder as the
Excel workbook.
I suspect that I could do this using the ThisWorkbook.Path and the
Image1.Picture - LoadPicture("File.wmf")
but I hoping that there is a more efficient way than using 15 IF
statements.
Any tips would be much appreciated.
Best regards,
|