I have the following macro that will take the url address (which is a link to a picture on a website) and create a picture of it on comment field. The problem is that I have to manually change the range of the cells including the urls. I would like to be able to only select the first cell and the macro would start making Picturecomments from there until the last row with data. E.g. I have urls in column B starting from row 3. I want to be able to select cell B3 and then run the macro. The macro should then run the insert picture into comment code from B3 until the last row with url in column B.
is the part that needs to be changed. Here is the whole macro. Im a novice in excel (understand some VBA)and I know this isn't anything huge but It will make my life so much easier.
Code:
Set rng = .Range("BM1:BM" & .Range("BM" & .Rows.Count).End(xlUp).Row)Set rng = .Range("BM1:BM" & .Range("BM" & .Rows.Count).End(xlUp).Row)
Code:
Sub PicturesToCommentField()
Dim rng As Range, cell As Range
With ActiveSheet
' ref on the code [URL]http://www.mrexcel.com/forum/excel-questions/730664-insert-image-into-comment.html[/URL]
Set rng = .Range("BM1:BM" & .Range("BM" & .Rows.Count).End(xlUp).Row)
If Right(Selection.Value, 3) = "jpg" Then
End If
End With
For Each cell In rng
cell.Select
On Error Resume Next
If Selection.Value <> "" Then
Selection.AddComment
Selection.Comment.Visible = False
Selection.Comment.Text Text:=""
Selection.Comment.Visible = True
Selection.Comment.Shape.Select True
Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Height = 250
Selection.ShapeRange.Width = 250
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 255, 255)
Selection.ShapeRange.Fill.UserPicture ActiveCell.Value
ActiveCell.Comment.Visible = False
Else
End If
Next
End Sub