Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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

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
Pulling pdf files from general folder to specific folder [email protected] Excel Discussion (Misc queries) 2 September 8th 09 09:41 PM
Moving a folder containing linked excel files? CNN Excel Discussion (Misc queries) 0 November 4th 08 03:29 PM
Macro help - Moving 2 cells from 100 separate files into new folder Steven Excel Discussion (Misc queries) 7 July 10th 07 07:47 PM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven Excel Discussion (Misc queries) 1 January 24th 06 03:28 PM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven[_2_] Excel Programming 1 January 24th 06 04:23 AM


All times are GMT +1. The time now is 11:16 AM.

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"