Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Changing Thumbnail Pictures in a UserForm

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,


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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,




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
changing pictures according to cell value frsm Excel Discussion (Misc queries) 7 July 5th 06 02:23 PM
Thumbnail ? razornt New Users to Excel 2 March 17th 05 12:20 AM
Thumbnail pictures in cells don't sort with rest of row Don Excel Discussion (Misc queries) 3 February 26th 05 01:11 PM
Add pictures to UserForm at runtime Dave[_33_] Excel Programming 1 December 6th 03 06:22 PM
Assigning the name of a userform/control to a changing string Brad Patterson Excel Programming 2 July 16th 03 11:00 PM


All times are GMT +1. The time now is 04:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"