Use a list from Excel to move files on computer
Ok I found this code and it works fine except that it needs the entire file name in column A to work. What I have in column A is a server name, so I need it find the server name in the file name. An example is the file name is American_server_pdol1298.mef , but in column A just the server name is listed , pdol1298 , This is the output of a script I run. So now I need to move the file into another folder.
:hi: thank you
[VBA]Sub MoveFiles()
Dim Cell As Range
Dim Filename As String
Dim Filepath As String
Dim NewPath As String
Dim Rng As Range
Dim RngEnd As Range
Dim Wks As Worksheet
Set Wks = ActiveSheet
Set Rng = Wks.Range("A1")
Set RngEnd = Wks.Cells(Rows.Count, Rng.Column).End(xlUp)
If RngEnd.Row < Rng.Row Then Exit Sub Else Set Rng = Wks.Range(Rng, RngEnd)
For Each Cell In Rng
Filename = Cell()
Filepath = Cell.Offset(0, 1)
NewPath = Cell.Offset(0, 2)
Name Filepath & "\" & Filename As NewPath & "\" & Filename
Next Cell
End Sub[/VBA]