How can i copy every file in a folder to a new location that starts with 12345 please
Cheers
Gibbo
How can i copy every file in a folder to a new location that starts with 12345 please
Cheers
Gibbo
[vba]Sub CopyEm()
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
'set your paths below
FSO.CopyFolder "C:\Windows\Desktop\New Folder", "C:\Windows\Desktop\12345"
Set FSO = Nothing
End Sub[/vba]
You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you
The major part of getting the right answer lies in asking the right question...
Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.
Gibbo
Do you mean every file that starts with 12345?
sorry norie, i did mean every spreadsheet that starts with 12345 in the same folder (e.g. C:\Test)
So 12345A.xls
12345B.xls and so on
Cheers gibbo
[VBA]
Sub CopyEm()
Dim oFSO As Object
Set oFSO = CreateObject("Scripting.FileSystemObject")
'set your paths below
oFSO.CopyFile "C:\MyTest\12345*.xls", "C:\NewDir\"
Set oFSO = Nothing
End Sub
[/VBA]
Hi Gibbo,
A minor adjustment to johnske's code to do this
[VBA]
Sub CopyEm()
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
'set your paths below
FSO.CopyFile "C:\Location\12345*.xls", "C:\NewLocation\"
Set FSO = Nothing
End Sub
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
I ve been racking my brains for hours and its that simple
thank you for putting me right
Gibbo