Results 1 to 12 of 12

Macro Image Help

Threaded View

  1. #1
    Registered User
    Join Date
    07-13-2011
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2007
    Posts
    12

    Macro Image Help

    I posted this a week or so ago but I havent heard back in a while after some intitial good feedback so I thought I would re-post.

    General Idea: I want Excel to call up an image to match a series of cells I have created. The logic is this: a user selects from 6 Yes/No fields, and depending on their combination, I want a specific image that is in a different workbook to appear.For example a chain of Yes/Yes/No should bring up a different image than Yes/No/Yes. The list of combinations will not be including duplicates, so 2+3 and 3+2 would bring up the same image.

    The following code and workbook is how far I have gotten, and there remain two problems I would like to fix:

    1) The worksheet only reacts and pastes a picture once the user changes cell C8. Can we manipulate this so each of the dropdown cells C4-C8, will paste an appropriate picture if changed?
    2) Each click of the C8 dropdown cell pastes the image on top of already pasted images. It gets in the way of the worksheet, it would be best if one click made the picture appear and another would not make a change unless it is to bring up another picture


     
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    If Not Intersect(Target, Range("C8")) Is Nothing Then
    
        If Range("C8").Value = "Yes" And Range("C7").Value = "Yes" And Range("C6").Value = "Yes" And _
        Range("C5").Value = "Yes" And Range("C4").Value = "Yes" Then
        
        Application.EnableEvents = False
            Sheets(2).Shapes("Picture 1").Copy
                Sheets(1).Range("e4").Select
                    ActiveSheet.Paste
                        
        ElseIf Range("C8").Value = "Yes" And Range("C7").Value = "Yes" And Range("C6").Value = "Yes" And _
        Range("C5").Value = "Yes" And Range("C4").Value = "No" Then
        Application.EnableEvents = False
            Sheets(2).Shapes("Picture 2").Copy
                Sheets(1).Range("D4").Select
                    ActiveSheet.Paste
                        
        ElseIf Range("C8").Value = "Yes" And Range("C7").Value = "Yes" And Range("C6").Value = "Yes" And _
        Range("C5").Value = "No" And Range("C4").Value = "No" Then
        Application.EnableEvents = False
            Sheets(2).Shapes("Picture 3").Copy
                Sheets(1).Range("D4").Select
                    ActiveSheet.Paste
                    
        ElseIf Range("C8").Value = "Yes" And Range("C7").Value = "Yes" And Range("C6").Value = "No" And _
        Range("C5").Value = "No" And Range("C4").Value = "No" Then
        Application.EnableEvents = False
            Sheets(2).Shapes("Picture 4").Copy
                Sheets(1).Range("D4").Select
                    ActiveSheet.Paste
                    
        ElseIf Range("C8").Value = "Yes" And Range("C7").Value = "No" And Range("C6").Value = "No" And _
        Range("C5").Value = "No" And Range("C4").Value = "No" Then
        Application.EnableEvents = False
            Sheets(2).Shapes("Picture 5").Copy
                Sheets(1).Range("D4").Select
                    ActiveSheet.Paste
                    
        ElseIf Range("C8").Value = "No" And Range("C7").Value = "No" And Range("C6").Value = "No" And _
        Range("C5").Value = "No" And Range("C4").Value = "No" Then
        Application.EnableEvents = False
            Sheets(2).Shapes("Picture 6").Copy
                Sheets(1).Range("D4").Select
                    ActiveSheet.Paste
        ElseIf Range("C8").Value = vbNullString Then
        Exit Sub
        Else
        MsgBox "You need to add more conditions"
         
       
        
        End If
        
    Else
    Exit Sub
    End If
    
    Application.EnableEvents = True
        
    End Sub
    Attached Files Attached Files
    Last edited by slamups21; 08-05-2011 at 01:44 PM.

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