PDA

View Full Version : edit pic code not working



willemeulen
12-18-2009, 04:51 AM
I inserted this code by right clicking excel icon and pasting it in there. Want the code to update picture in comment box when cells in range are changed.:banghead:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "K4:K36,K50:K82,K96:K128,K142:K174,K188:K220,K234:K266,K280:K312,K326:K358,K 372:K404,K418:K450"

Application.EnableEvents = False
On Error GoTo ws_exit

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then

Pic = "C:\SCimage\shape" & cell.Value & ".jpg"
On Error Resume Next
Target.ClearComments
On Error GoTo 0
With Target.AddComment

.Shape.Fill.UserPicture Pic
.Shape.Height = 175
.Shape.Width = 300
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

Dave
12-18-2009, 10:00 AM
Perhaps this...

Pic = "C:\SCimage\shape" & cell.Value & ".jpg"


needs to be this...

Pic = "C:\SCimage\shape" & target.Value & ".jpg"


HTH. Dave

willemeulen
12-22-2009, 12:44 PM
I'll give it a run in the new year. The code in particular was working on a selection of cells, I just want it to work when I change one in the range of cells.

Thanks

w