Image code

SPLUCENA

Board Regular
Joined
Feb 24, 2009
Messages
189
Hi Guys,

I have found this code (in search for an answer to my project-inserting an image if you have 2 list source ) from the book "EXCEL 2007 VBA & MACROS by Bill Jelen and Tracy Syrstad" and modified it to suite my project but I cannot make the image appear and so is the textbox to capture the data from the cell. What could have been wrong? I stayed late last night trying to figure out what could be wrong but my still learning brain almost explode last night with no right code in place. I need your expertise guys so I can close off this almost a month pending project of mine........Thanks for your help......!!!!!!!

Code:
Private Sub cb_product_Change()
    Dim ProdFound As Range
    With Range("A1")
        Set ProdFound = .Find(cb_product.Value)
        If ProdFound Is Nothing Then
            MsgBox ("Product not found!")
            cb_product.Value = ""
            Exit Sub
        Else
            With Range(ProdFound.Address)
            tb_prodcode = .Offset(0, 1)
            tb_prodname = .Offset(0, 2)
            On Error Resume Next
            Img_product.Picture = LoadPicture _
            ("C:\Documents and Settings\NOEL\Desktop\PHOTO\" & ProdFound & ".jpg")
            On Error GoTo 0
            End With
        End If
    End With
End Sub
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hi Guys,

I was able to figure it out. (I am thrilled!!!!!!) I just add the following code (highlighted in red) and alas it worked!!!!!!!!!!!! Now I can sleep with a smile knowing I can already finish my pend project.......

Code:
 Private Sub cb_product_Change()
    Dim ProdFound As Range
    With [COLOR=Red]Worksheets("PRODLIST")[/COLOR].Range("A:A")
        Set ProdFound = .Find(cb_product.Value)
        If ProdFound Is Nothing Then
            MsgBox ("Product not found!")
            cb_product.Value = ""
            Exit Sub
        Else
            With Range(ProdFound.Address)
            tb_prodcode = .Offset(0, 1)
            tb_prodname = .Offset(0, 2)
            On Error Resume Next
            Img_product.Picture = LoadPicture _
            ("C:\Documents and Settings\NOEL\Desktop\PHOTO\" & ProdFound & ".jpg")
            On Error GoTo 0
            End With
        End If
    End With
End Sub

Thanks guys!!!!!!! This site has inspired me a lot!!!!!!! I love this site....

splucena
 
Upvote 0

Forum statistics

Threads
1,214,605
Messages
6,120,476
Members
448,967
Latest member
visheshkotha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top