![]() |
Moving Files from one folder to another using ranges
I have two lists. Column A has a file path and Column B has a new file
path. I want the file in Column A to be moved to the path in Column B. For example: Column A Column B C:\Path1\file.tif C:\Path2\file.tif Everything I've searched for just goes to one specific folder. Anyone have any suggestions on how to do this? Niq |
Moving Files from one folder to another using ranges
Hi Dominique
Try Sub Move_Rename_One_File() 'You can change the path and file name Name "C:\Users\Ron\SourceFolder\Test.xls" As "C:\Users\Ron\DestFolder\TestNew.xls" End Sub You can use a cell reference instead of the path/file names You can create a loop to do all the cells in the range If you need help with that post back -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Dominique Feteau" wrote in message ... I have two lists. Column A has a file path and Column B has a new file path. I want the file in Column A to be moved to the path in Column B. For example: Column A Column B C:\Path1\file.tif C:\Path2\file.tif Everything I've searched for just goes to one specific folder. Anyone have any suggestions on how to do this? Niq |
Moving Files from one folder to another using ranges
Assuming that the values in both columns A and B have fully qualified
file names, you can use code like the following: Sub AAA() Dim R As Range For Each R In Range("A1:A10") If Dir(R.Text) < vbNullString Then ' file in A exists. delete file ' in B. ignore error if file in ' B does not exist. On Error Resume Next ' delete the file Kill R(1, 2).Text ' OR ' send the file to the RecycleBin ' see www.cpearson.com/Excel/Recycle.aspx Recycle R(1, 2).Text Name R.Text As R(1, 2).Text Else ' file in A does not exist. ' do nothing. End If Next R End Sub If the file named in column B already exists, it will be deleted. If you want to permanently and irrevocably delete it, use the line of code with the Kill function and delete the line of code with the Recycle function. If you want to send the file in column B to the Recycle Bin, delete the line of code with the Kill function and leave the line with Recycle in place. The code for the Recycle function is described and can be downloaded from www.cpearson.com/Excel/Recycle.aspx. Change the reference to A1:A10 to the appropriate range in column A. Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2009 Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Thu, 10 Sep 2009 13:24:47 -0500, "Dominique Feteau" wrote: I have two lists. Column A has a file path and Column B has a new file path. I want the file in Column A to be moved to the path in Column B. For example: Column A Column B C:\Path1\file.tif C:\Path2\file.tif Everything I've searched for just goes to one specific folder. Anyone have any suggestions on how to do this? Niq |
All times are GMT +1. The time now is 11:20 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com