I have a list of beginnings of filesnames in excel ,
I want to make a macro that will move them from one defined directory to the other
The file name are named like this AAAAXXX
AAAA- are unique numbers that i will put in excel
XXX- are also unique number but i want macro to skip them while moving/copying files
I tried using * after the file name but it read it as part of file name and not as a wildcard
I found out that Fso.Movefile doesnt work when i put variable in it . how can i solve it ?
Or i do need to use other command
Is it possible to do it without using library?
Sub movingfilename()
Dim a As String
Dim cell As Range
Dim locationstart As String
Dim locationend As String
Dim filename As String
Dim notfoundfiles As New Collection
Dim message As String
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
locationstart = "G:\Test\start\" & filename
locationend = "G:\Test\stop\" & filename
For Each cell In Range("A2:A" & Cells(Rows.Count, "A").End(-4162).Row)
If Not IsEmpty(cell) Then
filename = cell.Value
fso.MoveFile "G:\Test\start\filename*", "G:\Test\stop\"
End If
Next cell
End Sub
I want to move file from place a to place b. I have beginning of their names and want excel to move them ignoring rest of their name
