![]() |
Moving files based on cell references
I recognize that this is not truly an Excel thing but it's where the data
lives so I would like to continue to use Excel. I have a column that contains a filename and another column that contains a path. I would like to either rename all the files that exist in a specific folder OR copy the files from source path to target path. The data is structured below. The source/target path can be split if I need to as in drive letter versus a path, etc... I would prefer the macro to cascade down one row at a time once the file has been copied. If the copy command is difficult then I can just have them renamed and then I can do a manual copy. Column A(Filename) B(Source) C(target) file123.pdf c:\jason u:\archive file222.txt c:\jason u:\archive |
Moving files based on cell references
Try
Sub MyMacro() Dim lngRow As Long For lngRow = 1 To Cells(Rows.Count, "A").End(xlUp).Row FileCopy Range("B" & lngRow) & "\" & Range("A" & lngRow), _ Range("C" & lngRow) & "\" & Range("A" & lngRow) Next End Sub If this post helps click Yes --------------- Jacob Skaria "Rookie_User" wrote: I recognize that this is not truly an Excel thing but it's where the data lives so I would like to continue to use Excel. I have a column that contains a filename and another column that contains a path. I would like to either rename all the files that exist in a specific folder OR copy the files from source path to target path. The data is structured below. The source/target path can be split if I need to as in drive letter versus a path, etc... I would prefer the macro to cascade down one row at a time once the file has been copied. If the copy command is difficult then I can just have them renamed and then I can do a manual copy. Column A(Filename) B(Source) C(target) file123.pdf c:\jason u:\archive file222.txt c:\jason u:\archive |
Moving files based on cell references
It works perfectly to what I asked but I believe I left a part out. I
appreciate what you wrote but I also either need to delete the file after it's moved OR rename it after it's moved so I can then delete it later. Sorry for missing that in the first place. "Jacob Skaria" wrote: Try Sub MyMacro() Dim lngRow As Long For lngRow = 1 To Cells(Rows.Count, "A").End(xlUp).Row FileCopy Range("B" & lngRow) & "\" & Range("A" & lngRow), _ Range("C" & lngRow) & "\" & Range("A" & lngRow) Next End Sub If this post helps click Yes --------------- Jacob Skaria "Rookie_User" wrote: I recognize that this is not truly an Excel thing but it's where the data lives so I would like to continue to use Excel. I have a column that contains a filename and another column that contains a path. I would like to either rename all the files that exist in a specific folder OR copy the files from source path to target path. The data is structured below. The source/target path can be split if I need to as in drive letter versus a path, etc... I would prefer the macro to cascade down one row at a time once the file has been copied. If the copy command is difficult then I can just have them renamed and then I can do a manual copy. Column A(Filename) B(Source) C(target) file123.pdf c:\jason u:\archive file222.txt c:\jason u:\archive |
Moving files based on cell references
I made a mistake in my initial request could you review it again.
"Jacob Skaria" wrote: Try Sub MyMacro() Dim lngRow As Long For lngRow = 1 To Cells(Rows.Count, "A").End(xlUp).Row FileCopy Range("B" & lngRow) & "\" & Range("A" & lngRow), _ Range("C" & lngRow) & "\" & Range("A" & lngRow) Next End Sub If this post helps click Yes --------------- Jacob Skaria "Rookie_User" wrote: I recognize that this is not truly an Excel thing but it's where the data lives so I would like to continue to use Excel. I have a column that contains a filename and another column that contains a path. I would like to either rename all the files that exist in a specific folder OR copy the files from source path to target path. The data is structured below. The source/target path can be split if I need to as in drive letter versus a path, etc... I would prefer the macro to cascade down one row at a time once the file has been copied. If the copy command is difficult then I can just have them renamed and then I can do a manual copy. Column A(Filename) B(Source) C(target) file123.pdf c:\jason u:\archive file222.txt c:\jason u:\archive |
Moving files based on cell references
I get a file not found, even when the file is there. I added a watch
expression and they both look correct - however I am not sure why on the target folder you adding the file name to. I assumed it would be just a source and target folder. "Jacob Skaria" wrote: Try Sub MyMacro() Dim lngRow As Long For lngRow = 1 To Cells(Rows.Count, "A").End(xlUp).Row FileCopy Range("B" & lngRow) & "\" & Range("A" & lngRow), _ Range("C" & lngRow) & "\" & Range("A" & lngRow) Next End Sub If this post helps click Yes --------------- Jacob Skaria "Rookie_User" wrote: I recognize that this is not truly an Excel thing but it's where the data lives so I would like to continue to use Excel. I have a column that contains a filename and another column that contains a path. I would like to either rename all the files that exist in a specific folder OR copy the files from source path to target path. The data is structured below. The source/target path can be split if I need to as in drive letter versus a path, etc... I would prefer the macro to cascade down one row at a time once the file has been copied. If the copy command is difficult then I can just have them renamed and then I can do a manual copy. Column A(Filename) B(Source) C(target) file123.pdf c:\jason u:\archive file222.txt c:\jason u:\archive |
All times are GMT +1. The time now is 10:01 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com