Posting files to two paths

ncoatney

New Member
Joined
Jan 4, 2018
Messages
6
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
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Isn't this simply

Code:
If OldPath = "" Then
    CELL.Interior.ColorIndex = 3
Else
    If Dir(OldPath) <> "" And CELL.Offset(0, 13) = "YES" Then
        fs.copyfile OldPath, NewPath
    Else
        fs.copyfile OldPath, SOMEWHERE ELSE
        Cells(0, 1).Interior.ColorIndex = 3
    End If
End If
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,334
Members
452,636
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top