+ Reply to Thread
Results 1 to 6 of 6

Autocompletion and Icons

Hybrid View

  1. #1
    Registered User
    Join Date
    01-14-2009
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Autocompletion and Icons

    Supposebly impossible

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,461

    Re: Autocompletion and Icons

    You can use event code behind the spreadsheet to cell changed cell content and insert image if required.

    Private Sub Worksheet_Change(ByVal Target As Range)
    
        If Target.Cells.Count = 1 Then
            If Not Union(Target, Range("B3:B10")) Is Nothing Then
                If StrComp(Target.Value, "HDD1", vbTextCompare) = 0 Then
                    ActiveSheet.Shapes.AddPicture _
                                "c:\temp\temp.gif", _
                                 True, True, Target.Left, Target.Top, _
                                 Target.Width, Target.Height
                End If
            End If
        End If
        
    End Sub
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    01-14-2009
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    9

    Talking Re: Autocompletion and Icons

    Quote Originally Posted by Andy Pope View Post
    You can use event code behind the spreadsheet to cell changed cell content and insert image if required.

    Private Sub Worksheet_Change(ByVal Target As Range)
    
        If Target.Cells.Count = 1 Then
            If Not Union(Target, Range("B3:B10")) Is Nothing Then
                If StrComp(Target.Value, "HDD1", vbTextCompare) = 0 Then
                    ActiveSheet.Shapes.AddPicture _
                                "c:\temp\temp.gif", _
                                 True, True, Target.Left, Target.Top, _
                                 Target.Width, Target.Height
                End If
            End If
        End If
        
    End Sub
    Sweet thanks, I'll try it out.
    Is "case" possible in this code? To easier list more items. Or could I use a dynamic file-value so that it uses the entered text as file-name?
    Ex. c:\temp\HDD1.gif would be used if [HDD1] was entered, and for all text entered within [] or maybe img[value]
    I'm guessing I can figgure out how to use case in this senario, not sure if I can wrap my mind around the image location values, unless fixed for each case.
    Thanks again,
    Bb

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,461

    Re: Autocompletion and Icons

    Private Sub Worksheet_Change(ByVal Target As Range)
    
        Dim strFilename As String
        
        If Target.Cells.Count = 1 Then
            If Not Union(Target, Range("B3:B10")) Is Nothing Then
                Select Case UCase(Target.Value)
                Case "HDD1"
                    strFilename = "c:\temp\temp.gif"
                End Select
                
                If Len(strFilename) > 0 Then
                    ActiveSheet.Shapes.AddPicture _
                                strFilename, _
                                 True, True, Target.Left, Target.Top, _
                                 Target.Width, Target.Height
                End If
            End If
        End If
        
    End Sub

+ 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