Dears,
Would you be so kind and help me with the modification of the script below? I would like to add the function that will allow me to choose a folder manually (with Application.FileDialog(msoFileDialogFolderPicker function I guess)
Also, it would be great if the code will allow me to choose where the images will be added directly from the excel (for example by a msg box or only based on the active cell)
Description of the current code: Macro allows insert images according to the names from defined folder.
Goal: Insert a lot of images from a lot of folders with a different paths.
Sub AddPictures()
Dim cel As Range, Pictures As Range, PictureFileNames As Range, targ As Range
Dim j As Long, n As Long
Dim flPath As String, flName As String
Dim shp As Shape
flPath = "C:\Temp\" 'Path to pictures
With ActiveSheet
Set Pictures = .Range("B2") 'First picture goes here
Set PictureFileNames = .Range("A2") 'First picture file name found here
Set PictureFileNames = Range(PictureFileNames, .Cells(.Rows.Count, PictureFileNames.Column).End(xlUp)) 'All picture file names in this column
n = Application.CountA(PictureFileNames)
If n = 0 Then Exit Sub
'Delete existing pictures
For Each shp In .Shapes
If shp.Type = msoPicture Then
If shp.TopLeftCell.Row = Pictures.Row Then shp.Delete
End If
Next
'Add new pictures, resized to fit the cell
For Each cel In PictureFileNames
If cel.Value <> "" Then
j = j + 1
Set targ = Pictures.Cells(j, 1)
Set shp = .Shapes.AddPicture(Filename:=flPath & cel.Value, linktofile:=msoFalse, savewithdocument:=msoCTrue, _
Left:=targ.Left, Top:=targ.Top, Width:=targ.Width, Height:=targ.RowHeight)
shp.Name = "pic" & cel.Value
End If
Next
End With
End Sub
Thank you very much for support.

flPath & cel.Valuematch the respective picture location? If yes, in which way to useFileDialog? Do you have multiple folders having the same pictures name?