Good Morning
I have the following Macro that someone helped me with, It was moving some files over to the end location but now it doesnt seem to be doing that, What I wanted to do is write the final folder path to Cell F2 once it has run through the macro.
Sub Create_Folder_Move_Files()
Dim strDefpath, mainfolder, subfolder, subsubfolder, strPathname As String
Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error Resume Next ' If directory exist goto next line
strDefpath = "\\ccfilesvr\shared\membership services\operations\supervisors\RESOURCE AREA stats & info\Statistics\Daily Stats Import\" 'Default path name
mainfolder = Sheets("Move & Rename").Range("C2").Value ' stores value of C2 cell
subfolder = Sheets("Move & Rename").Range("D2").Value ' stores value of D2 cell
subsubfolder = Sheets("Move & Rename").Range("E2").Value ' stores value of E2 cell
If IsEmpty(mainfolder) Then Exit Sub
MkDir strDefpath & mainfolder ' Check or create mainfolder
strPathname = strDefpath & "\" & mainfolder
If IsEmpty(subfolder) Then Exit Sub
MkDir strPathname & "\" & subfolder ' Check or create subfolder
strPathname = strDefpath & "\" & mainfolder & "\" & subfolder
If IsEmpty(subsubfolder) Then Exit Sub
MkDir strPathname & "\" & subsubfolder ' Check or create subsubfolder
strPathname = strDefpath & "\" & mainfolder & "\" & subfolder & "\" & subsubfolder
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
I then have this Macro set up to move the files
Sub Move_CDN_CC()
Dim strFile As String, strNewFile As String
Const strSourcePath As String = "A:\"
Const strDestinationPath As String = "P:\membership services\operations\supervisors\RESOURCE AREA stats & info\Statistics\Daily Stats Import\2014\"
strNewFile = Sheets("Move & Rename").Range("A2").Value & " " & _
Format(Sheets("Move & Rename").Range("B2").Value, "dd mmm yy") & ".xls"
If Dir$(strDestinationPath & strNewFile) <> "" Then
MsgBox "There is already an existing file named " & vbLf & strDestinationPath & strNewFile, _
vbExclamation, "Dated File Name Exists"
Exit Sub
End If
strFile = Dir$(strSourcePath & "CDN CC*")
If strFile <> "" Then
Name (strSourcePath & strFile) As (strDestinationPath & strNewFile)
Else
MsgBox "No file found. ", , "File Not Found"
End If
End Sub
I will change this line
Const strDestinationPath As String = "P:\membership services\operations\supervisors\RESOURCE AREA stats & info\Statistics\Daily Stats Import\2014\"
To point to the cell with the final path string in it
Const strDestinationPath As String = "Sheets("Move & Rename").Range("F2").Value"
I assume that will work?
Bookmarks