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
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