I have an Excel sheet that has date in this format:
Group ID Complete Path Filename 0 C:\Folder1\R0CVNM6.pdf R0CVNM6.pdf 0 J:\FolderA\f303919232.pdf f303919232.pdf 1 C:\Folder1\R0YC44P.pdf R0YC44P.pdf 1 J:\FolderA\c34563.pdf c34563.pdf 1 H:\FolderZ\t342332.pdf t342332.pdf 1 K:\FolderS\j73838a.pdf j73838a.pdf
etc...
The Group ID goes up to 51374 but there are 115590 rows in this spreadsheet with the Group ID having a minimum of 2 identical numbers (i.e. two 0's, four 1's, etc.). The maximum count having the same Group ID is 21.
I would like my script to go through each row 0 through 115590 and take the 1st row of each Group ID and move that file to a folder and all the rest with the same Group ID, move it to a different folder. Then move on to the next Group ID and do the same. Repeat...
Here is my first attempt, but it only copied 1 file and then skipped the rest.
There has to be a better approach to this.Sub MoveFiles() zz = 2 For j = 0 To 20 '51374 aa = Range("A" & zz) bb = Range("B" & zz) cc = Range("C" & zz) If j = aa And fth = 0 Then fth = 1 Name bb As "J:\kfolder\" & cc End If If j = aa And fth = 1 Then Name bb As "J:\ffolder\" & cc End If zz = zz + 1 Next j End Sub
Also, some of these filenames (very few) have special characters and Excel errors on these. I would like Excel to just ignore and maybe flag or highlight these.
I do know how to use Kill to delete the final files, but I want to get the code working first before deleting a bunch of files.
Thank you,
Zune





Reply With Quote