Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Macro to move files from one directory to another

I figured out what I needed. This is the macro that works:

ub Transfer()

newPath = InputBox("Please enter the directory name", "Directory Name") '
For i = 2 To Cells(Rows.Count, "A").End(xlUp).row
currentPath = Cells(i, "A").Value
Filename = Cells(i, "G").Value
Debug.Print currentPath, Filename, newPath, Filename
'copy currentPath & "\" & Filename As newPath & "\" & Filename
FileCopy currentPath & "\" & Filename, newPath & "\" & Filename

Next i

End Sub

"Bob Phillips" wrote:

Something like

currentPath = "C:\myFiles\"
newPath = "Y:\abc\"
For i = 2 To Cells(Rows.Count, "A").End(xlUp).row
Name currentPath & Cells(i,"A").Value _
newPath & Cells(i,"A").Value
next i

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Barb Reinhardt" wrote in message
...
I want to create a macro to move files from one server to another.
Basically, I'd want to move anything that has a .XXX at the end. I want

to
move the files as listed in the active workbook and determine the number

of
files to move based on the info stored in column A.
For i = 2 To Cells(Rows.Count, "A").End(xlUp).row

Next i

The directory location is stored in column B of my workbook.
(Y:\abc\file.xxx)

Can someone assist?

Thanks,
Barb Reinhardt




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Move all files from one directory to another Prema Excel Programming 5 July 15th 05 12:09 AM
move all files in a directory into another [email protected] Excel Programming 1 January 24th 05 02:53 PM
Move files from one directory to another: if they are there Michael McClellan Excel Programming 12 June 28th 04 12:42 AM
macro to move contents of directory Harvey[_3_] Excel Programming 0 February 9th 04 07:36 PM
run macro for all files in the directory igor Excel Programming 3 July 17th 03 03:48 PM


All times are GMT +1. The time now is 07:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"