PDA

View Full Version : [SOLVED:] Move an excel file to another folder



oam
10-11-2016, 09:55 PM
Does anyone have a code that will move an excel file from one server folder to another server folder? The path of the file will have a full path to include the file extension i.e. D\Timesheets\Smith, Jane K.xlsx. There are a number of codes on the web that make a copy and save a file to another folder but I can not find any code that will move a file from one folder to another.

Thank you for your help

mancubus
10-12-2016, 12:35 AM
:)
https://www.google.com.tr/#safe=active&q=excel+vba+move+a+file+from+one+folder+to+another

one from vbax:
http://www.vbaexpress.com/forum/showthread.php?47078-VBA-Code-to-move-files-to-another-folder

snb
10-12-2016, 01:09 AM
Name "D:\Timesheets\Smith, Jane K.xlsx" As "G:\OF\Smith, Jane K.xlsx"

Please use F1 in the VBEditor.

oam
10-12-2016, 03:18 PM
I am such a dunce; I am always forgetting to tell you pertinent information. All I need is to move an excel file from one folder location to another with a predetermined path of where the file is located and where the file is going, no names changes just different folders.
Thank you for quick response.

oam
10-12-2016, 07:27 PM
Upon further searching, I found the following code that does exactly what I needed to complete.
Thank you for all your help and responses.

Sub Move_File()
'Path/filename format ="C:\Folder\Folder\Filename.xls"
OldName = Sheet1.range("A1").Value
NewName = Sheet1.range("B1").Value
Name OldName As NewName
End Sub

snb
10-13-2016, 01:43 AM
Why did you ignore the suggestion in #3 ?
redundant variables in you code.


Sub Move_File()
Name Sheet1.range("A1").Value As Sheet1.range("B1").Value
End Sub

oam
10-13-2016, 03:49 PM
snb,

I didn't understand your code until I came across this other code that was more apparent to me but I failed to go back and review the responses before.

Your code does work well and it is simpler, sorry for not understanding it when you posted it but thank you for helping me understand it.

mancubus
10-14-2016, 11:58 PM
consider marking the thread as solved from threadtools. :)