-
edit pic code not working
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.
[vba]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, K372: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[/vba]
Last edited by Aussiebear; 12-23-2009 at 06:37 AM.
Reason: Added VBA tags to code
-
Perhaps this...
[VBA]
Pic = "C:\SCimage\shape" & cell.Value & ".jpg"
[/VBA]
needs to be this...
[VBA]
Pic = "C:\SCimage\shape" & target.Value & ".jpg"
[/VBA]
HTH. Dave
-
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules