Hi All,
I have this script that is working partially as intended - when importing the photos into the spreadsheet its posting them over the cell and not into the cell
In column B i have the names of the photos id like to import, column C is where id like to import the photos into
Ive attempted to alter the code to the following but im getting an error (insertpictureincell)
id also like the picture to resize to fit the cell upon import , but im abit unsure on how to do this
a solution would be hugely appreciated !!
I have this script that is working partially as intended - when importing the photos into the spreadsheet its posting them over the cell and not into the cell
In column B i have the names of the photos id like to import, column C is where id like to import the photos into
VBA Code:
Sub InsertPictures()
Const fPath = "C:\Madeupfilepath"
Dim cel As Range, picPath As String
For Each cel In Range("B2", Range("B" & Rows.Count).End(xlUp))
On Error Resume Next
picPath = fPath & "\" & cel.Value & ".jpg"
If Not Dir(picPath, vbDirectory) = vbNullString Then
With cel.Parent.Pictures.Insert(picPath)
With .ShapeRange
.LockAspectRatio = msoFalse
.Width = 70
.Height = 70
End With
.Left = cel.Offset(0, 1).Left
.Top = cel.Offset(0, 0).Top
End With
End If
Next cel
End Sub
Ive attempted to alter the code to the following but im getting an error (insertpictureincell)
VBA Code:
Sub InsertPictures()
Const fPath = "C:\Madeupfilepath"
Dim cel As Range, picPath As String
For Each cel In Range("B2", Range("B" & Rows.Count).End(xlUp))
On Error Resume Next
picPath = fPath & "\" & cel.Value & ".jpg"
If Not Dir(picPath, vbDirectory) = vbNullString Then
With cel.Parent.Pictures.InsertPictureInCell(picPath)
With .ShapeRange
.LockAspectRatio = msoFalse
.Width = 70
.Height = 70
End With
.Left = cel.Offset(0, 1).Left
.Top = cel.Offset(0, 0).Top
End With
End If
Next cel
End Sub
id also like the picture to resize to fit the cell upon import , but im abit unsure on how to do this
a solution would be hugely appreciated !!