+ Reply to Thread
Results 1 to 12 of 12

Question regarding Macro for pop-up window with picture

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2016
    Posts
    964

    Question regarding Macro for pop-up window with picture

    I'd sure appreciate anyone's help (if possible) reference creating a macro, which would allow me to click on a particular cell, which will have an ID number (1 through 34), each ID# is attributed to a particular employee. These ID# are located in my spreadsheet in columns B & G, and the ID #'s begin initially in B6 & G6 and continue downward to B34 & G34. These ID #'s are used in a vlookup type formula which covers 35 pages of this workbook. What I'd like to do is be able to click on any cell between B6& B34 (and/or the same in G6&G34), which has a particular ID # in it and have the photo of that particular employee designated with that ID# pop up in a window generated by the macro. I hope this makes sense! Any help would be greatly appreciated. My 1st sheet in my workbook is my "lookup" tab, which contains my ID# list and numbering sequence affiliated to each employee. So I'm not sure if I'd need to put the photograph of the employee in a column next to the employees name or have a folder designated with all my pictures in a certain directory, etc. Thanks for any suggestions if this in fact even possible...

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Lilsnoop,

    Saving the pictures in a folder is Ok if you aren't moving your workbook from computer tot computer. One way to have the pictures pop up in the cells when the mouse is on the cell is to place the picture in a comment for the cell. If this is of interest to you , I'll post the macro to read the pictures from a folder an load them into the cell comments.

    Sincerely,
    Leith Ross

  3. #3
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2016
    Posts
    964

    Thanks Leith!

    That would be great! I appreciate the help!

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Lilsnoop,

    If you post your workbook it will be both easier and faster for me to customize the macro. Can you do post it? Here is the basic macro code. This adds one picture at a time.
    Sub AddPictureToComment(ByRef Cell As Range, ByVal FolderPath As String, ByVal FileName As String)
        
       Dim Cmnt As Excel.Comment
       Dim Ext As String
       
         If Right(FolderPath, 1) <> "\" Then FolerPath = FolderPath & "\"
         Ext = Right(FileName, Len(FileName) - InStrRev(FileName, "."))
        
         If Dir(FolderPath & FileName) = "" Then
            MsgBox FolderPath & FileName & " not found.", vbCritical
            Exit Sub
         End If
         
         Select Case Ext
           Case Is = "bmp", "gif", "jpeg", "jpg", "png", "wmf"
             Set Cmnt = Cell.Comment
               If Cmnt Is Nothing Then
                  Set Cmnt = Cell.AddComment(Text:="")
               End If
             Cmnt.Shape.Fill.UserPicture FolderPath & FileName
         End Select
            
    End Sub
    Sincerely,
    Leith Ross

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Have a look at Andy Pope's example

    http://www.andypope.info/fun/picviewer.htm
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2016
    Posts
    964

    Thanks Leith & Roy

    Leith I'm attaching a smaller version of my workbook. This example has my lookup table and four other employee sheets. My 2nd tab (worksheet) titled "Delmar Smith" has data entered in columns B6 & G6, representing employees identified in the lookup table. This I believe should show you my intent. The employees id'd in B6 & G6 per their individual ID# covered an 8 hr shift for "Delmar Smith" and each employee wages per date are located and entered. What I'd like to do as expressed earlier, is click on the cell B6 or other related cells and instead of trying to figure out who employee #4 or #2 is, is to just click on the cell and have a photo of the employee appear as a macro. The ID numbering system is needed for my lookup functionality for wages, etc. I appreciate all your help!
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1