I am trying to copy designated pdf files from multiple folders into one designated folder (DestFolder) based upon file names and folder locations filtered on a spreadsheet (sheet 1).
The columns of data on “Sheet 1” span from column B to AY. I have code that has already successfully filtered this data based on criteria. The filters and headers are in row 2. Folder Paths exist in column “Q” and file names are in column “O”. I need to increment through the filter list and copy a pdf file with the name designated in column “O” which is located in folder designated by the path in column “Q” of the same row. I then need to paste that pdf file in a folder called “DestFolder”. I then need to loop to the next row to do the same thing until I reach the end of the filtered list. I have tried to use a mix match of code I have found. No errors but it is stopping at the first filtered line in column “O”.
Sheets("sheet 1").Activate
ActiveSheet.Unprotect Password:=""
Dim FolderName As Variant
Dim FileName As Variant
Range("Q2").Select
ActiveCell.Offset(1, 0).Activate
Do Until Selection.EntireRow.Hidden = False
If Selection.EntireRow.Hidden = True Then
ActiveCell.Offset(1, 0).Activate
End If
FolderName = ActiveCell.Value
ActiveCell.Offset(0, -2).Select
FileName = ActiveCell.Select
FileCopy "FolderName" & FileName.Value, "DestFolder" & FileName.Value
Loop
The columns of data on “Sheet 1” span from column B to AY. I have code that has already successfully filtered this data based on criteria. The filters and headers are in row 2. Folder Paths exist in column “Q” and file names are in column “O”. I need to increment through the filter list and copy a pdf file with the name designated in column “O” which is located in folder designated by the path in column “Q” of the same row. I then need to paste that pdf file in a folder called “DestFolder”. I then need to loop to the next row to do the same thing until I reach the end of the filtered list. I have tried to use a mix match of code I have found. No errors but it is stopping at the first filtered line in column “O”.
Sheets("sheet 1").Activate
ActiveSheet.Unprotect Password:=""
Dim FolderName As Variant
Dim FileName As Variant
Range("Q2").Select
ActiveCell.Offset(1, 0).Activate
Do Until Selection.EntireRow.Hidden = False
If Selection.EntireRow.Hidden = True Then
ActiveCell.Offset(1, 0).Activate
End If
FolderName = ActiveCell.Value
ActiveCell.Offset(0, -2).Select
FileName = ActiveCell.Select
FileCopy "FolderName" & FileName.Value, "DestFolder" & FileName.Value
Loop