Solved

Display Pics while selecting cell in a certain Range

Posted on 2013-06-14
5
160 Views
Last Modified: 2013-07-10
excel 2010

Range is 02:02500

When i move my from cell to cell in The Range 02:02500

I would like a pic displayed for the value in that cell.

I have a folder(s) of pics:

The following code works for me using a userform and  a listbox value  to get the correct pic.


What I need:
To move from cell to cell and bring up a useform with a just a pic box with an image in it.
from the value that is in the cell.

Thanks
fordraiders


GskuL = frmResultAll.ListBox1.Column(1)
  End If

End If


    Gstart = Left(GskuL, 1)
    Gstart = Gstart
 
         
        Select Case Gstart
        Case 1
        gJpg = "C:\Gr_Images_2013\1_JPG\"
        Case 2
        gJpg = "C:\Gr_Images_2013\2_JPG\"
        Case 3
        gJpg = "C:\Gr_Images_2013\3_JPG\"
        Case 4
        gJpg = "C:\Gr_Images_2013\4_JPG\"
        Case 5
        gJpg = "C:\Gr_Images_2013\5_JPG\"
        Case 6
        gJpg = "C:\Gr_Images_2013\6_JPG\"
        Case 7
        gJpg = "C:\Gr_Images_2013\7_JPG\"
        Case 8
        gJpg = "C:\Gr_Images_2013\8_JPG\"
        Case 9
        gJpg = "C:\Gr_Images_2013\9_JPG\"
        Case Else
       
        End Select
       
     
       
        On Error Resume Next
        If Gsku = "" Then
                   fPathNF = "C:\Gr_Images_2013\"
            frmResultAll.Image1.Picture = LoadPicture(fPathNF & "NOTAVAIL.JPG")
        Else
                'Look in the directory where this workbook is located.
              '  fPath = "C:\Gr_Images_2013\"
                fPath = gJpg '"C:\Gr_Images_2013\"
              '  On Error Resume Next
                 'If a matching picture is found then display it.
                frmResultAll.Image1.Picture = LoadPicture(fPath & Gsku & ".jpg")
                 'If No picture found then display the default picture.
                 
                If Err = 0 Then
                  frmResultAll.Repaint
                Exit Sub
                End If
                fPathNF = "C:\Gr_Images_2013\"
                frmResultAll.Image1.Picture = LoadPicture(fPathNF & "NOTAVAIL.JPG")
          frmResultAll.Repaint
        End If
0
Comment
Question by:fordraiders
  • 3
  • 2
5 Comments
 
LVL 22

Accepted Solution

by:
rspahitz earned 500 total points
ID: 39248785
Bringing up a userform is easy enough.

In VB, add a user form (default name is UserForm1 then add this code to, maybe, the sheet's Worksheet_SelectionChange event prodedure:

UserForm1.Show vbModeless

Open in new window


you'll then need to add code like yours above into the Initialize event procedure for that form:

Private Sub UserForm_Initialize()
...
    UserForm1.Picture = LoadPicture(fPath & Gsku & ".jpg")
End Sub

Open in new window


Also, FYI, some of your code can be rewritten to make it easier to read, such as the entire case statement with this:

gJpg = "C:\Gr_Images_2013\" & Gstart & "_JPG\"

Open in new window

0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 39282777
Thanks
0
 
LVL 3

Author Comment

by:fordraiders
ID: 39313287
matt, got everything to working.

but i cant use my arrow keys to navigate while the userform is up ?

I can use the move to go from cell to cell.
0
 
LVL 3

Author Comment

by:fordraiders
ID: 39313370
rspahitz
got everything to working.

but i cant use my arrow keys to navigate while the userform is up ?

I can use the move to go from cell to cell.

the form is set to modeless and showmodal =  false
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 39315208
if the form is modeless, then you should be able to navigate with arrows on the sheet, but it will need to have the focus first.
Is that what you meant?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now