Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Excel 2010 Insert photo in comment from value of adjacent cell

Status
Not open for further replies.

ecoservices

Technical User
Mar 6, 2014
3
US
I have a project where I am adding comments with photos to cells.
The excel sheet has a product number in column A, company name in column B, product name in column C etc.
I am using the following macro for column A to add an image of the product to the pop up comment for the product number. I have a separate file for jpg images for 1) the product image 2) the extended product description 3) the ingredients. Each of the images for the product are labeled by the product number in files names images, proddesc ( product description), prodingr (product ingredients)
This macro works well for column A where the product number is use to bring in the product image to the comment. I now want to modify the macro to use in column B and C. In B to add the Ingredients to the comment box, C to display the Product description in the comment box.
I'm not figuring out how to make the macro use the value in column A for the lookup of the file number in either the product description of ingredient file. I'm thinking this is an offset function but am not being able to make it work.
Any help is appreciated - thanks!
Sub Macro1()

'
' Macro1 Macro
'
For Each cell In Selection
On Error Resume Next
MyPic = "E:\marchfolder\images\" & ActiveCell.Value & ".jpg"
With cell.AddComment
.Shape.Fill.UserPicture MyPic
.Shape.Height = 300
.Shape.Width = 300
End With
Next cell

'
End Sub

 
hi,

you were using ActiveCell rather than [highlight #FCE94F]Cell[/highlight]...

Code:
Sub Macro1()

'
' Macro1 Macro
'
    On Error Resume Next
    
    For Each Cell In Selection
        MyPic = "E:\marchfolder\images\" & [highlight #FCE94F]Cell[/highlight].Value & ".jpg"
        With Cell.AddComment
            .Shape.Fill.UserPicture MyPic
            .Shape.Height = 300
            .Shape.Width = 300
        End With
    Next Cell
'
End Sub

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
Hello Skip - thank you.
This works if I am in the cell in column A which holds the product number value.
If I want to use it in Column C to pop up the comment using the value from column A ( the product number for look up in the product description or product ingredients files, how do I add the offset ( Offset (0,-2) for the lookup?
Thanks
 

Code:
        MyPic = "E:\marchfolder\images\" & Cells(Cell.row, "A").Value & ".jpg"

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top