I'm needing some help moving files into two different paths if certain criteria is met.
Below is what I currently have. right now it moves all files left on sheet into the same folder.
What I'm aiming for is if the "oldpath" is not blank and row 13 is "yes" then move to a certain folder, and if row 13 is no or blank move elsewhere.
Set MyRng = Selection
For Each CELL In MyRng
Call GetVals("TRUMPF 5170S-NEED PROGRAMMED", CELL.Row)
MaterialFolder = myFolder & "" & material
If fs.FolderExists(MaterialFolder) Then
Else
fs.CreateFolder (MaterialFolder)
End If
OldPath = psmLoc
Debug.Print OldPath
NewPath = MaterialFolder & "" & partName & Right(psmLoc, 4)
Debug.Print NewPath
If OldPath = "" Then
CELL.Interior.ColorIndex = 3
Else
If Dir(OldPath) <> "" And CELL.Offset(0, 13) = "YES" Then
fs.copyfile OldPath, NewPath
Else
Cells(0, 1).Interior.ColorIndex = 3
End If
End If
Next CELL
Below is what I currently have. right now it moves all files left on sheet into the same folder.
What I'm aiming for is if the "oldpath" is not blank and row 13 is "yes" then move to a certain folder, and if row 13 is no or blank move elsewhere.
Set MyRng = Selection
For Each CELL In MyRng
Call GetVals("TRUMPF 5170S-NEED PROGRAMMED", CELL.Row)
MaterialFolder = myFolder & "" & material
If fs.FolderExists(MaterialFolder) Then
Else
fs.CreateFolder (MaterialFolder)
End If
OldPath = psmLoc
Debug.Print OldPath
NewPath = MaterialFolder & "" & partName & Right(psmLoc, 4)
Debug.Print NewPath
If OldPath = "" Then
CELL.Interior.ColorIndex = 3
Else
If Dir(OldPath) <> "" And CELL.Offset(0, 13) = "YES" Then
fs.copyfile OldPath, NewPath
Else
Cells(0, 1).Interior.ColorIndex = 3
End If
End If
Next CELL