Instead of using the numbers, you could just name the picture files by the
person's name--or just use an additional column that contains the real name of
the picture file.
Option Explicit
Sub testme01()
Dim myPict As Picture
Dim curWks As Worksheet
Dim myRng As Range
Dim myCell As Range
Dim myPictName As Variant
Set curWks = ActiveSheet
With curWks
Set myRng = .Range("c2", .Cells(.Rows.Count, "C").End(xlUp))
End With
For Each myCell In myRng.Cells
If Trim(myCell.Value) = "" Then
'do nothing
ElseIf Dir(CStr(myCell.Value)) = "" Then
'picture not there!
MsgBox myCell.Value & " Doesn't exist!"
Else
With myCell.Offset(0, 3) '3 columns to the right of C (F)
Set myPict = myCell.Parent.Pictures.Insert(myCell.Value)
myPict.Top = .Top
myPict.Width = .Width
myPict.Height = .Height
myPict.Left = .Left
myPict.Placement = xlMoveAndSize
End With
End If
Next myCell
End Sub
I had things like:
c:\my documents\my pictures\mypict.jpg
in those cells.
MS wrote:
I'm putting a column of pictures of people next to a column with their
names. If I have the pictures together in a folder, with the photo file
names numbered with the corresponding row numbers that the pictures go in,
is there a way to record a macro so that (for instance) 28.jpg will go into
the picture column in row #28, then 29.jpg will go into the picture column
in row #29, etc. In other words, insert a whole series of pictures
(filenames the same as their appropriate row numbers) in their correct
places, by initiating one macro?
If anyone has any idea of how that could be done, I would greatly appreciate
any suggestions on how to do that.
--
Dave Peterson