I have in A2 a text with a name. and in b2, c2, d2, e2, f2 I have links with pictures. I would like to download all the links and rename them with the name of A2 but adding to the file name _01, _02, _03, _04, _05 depending if the picture is from b2, c2, etc.
I have made a picture for explaining it better. http://oi57.tinypic.com/119cx6v.jpg
There are more than one row, so after downloading one row it would have to keep downloading the others.
I have found the following code in another post, it is similar but not exactly what I need to do. Please any help would be appreciate it.
Option Explicit Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" _ Alias "URLDownloadToFileA" (ByVal pCaller As Long, _ ByVal szURL As String, ByVal szFileName As String, _ ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long Dim Ret As Long '~~> This is where the images will be saved. Change as applicable Const FolderName As String = "C:\pato\" Sub Sample() Dim ws As Worksheet Dim LastRow As Long, i As Long Dim strPath As String '~~> Name of the sheet which has the list Set ws = Sheets("Sheet1") LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row For i = 2 To LastRow '<~~ 2 because row 1 has headers strPath = FolderName & ws.Range("A" & i).Value & ".jpg" Ret = URLDownloadToFile(0, ws.Range("B" & i).Value, strPath, 0, 0) If Ret = 0 Then ws.Range("C" & i).Value = "File successfully downloaded" Else ws.Range("C" & i).Value = "Unable to download the file" End If Next i End Sub