I have used this code to move batches of files from one folder to another (somewhat manually bc I have to hunt through a large batch of files to select what I want moved) but now need more specifics built in and not sure how? Hoping it's a good starting point that can be easily updated but if not, happy to try something new that will do the task!
Current script does this:
Excel file has a table that holds a list of file names
Prompts user to choose SOURCE folder, Prompts user to then choose the MOVE TO folder
Current task need:
Look specifically at the last 5 characters of each cell in that list (for the Julian dates found in the last 5 chars of the file name) and either just SELECT THEM --- so I can then select the MOVE TO FOLDER and have them moved into their appropriate Fiscal Month Folder for Reconciliation.
This orig script already allows me to pick the SOURCE folder and already allows me to then pick the MOVE TO folder so no code is needed for that part..
Need it to look for matching Julian code, IF MATCH FOUND, then auto-select the matches in the file folder that match the Excel list/ for moving..(so I don't have to hunt n' pic through tons within a folder or list)
Sub movefiles() 'Updateby Extendoffice Dim xRg As Range, xCell As Range Dim xSFileDlg As FileDialog, xDFileDlg As FileDialog Dim xSPathStr As Variant, xDPathStr As Variant Dim xVal As String On Error Resume Next Set xRg = Application.InputBox("Please select the file names:", "KuTools For Excel", ActiveWindow.RangeSelection.Address, , , , , 8) If xRg Is Nothing Then Exit Sub Set xSFileDlg = Application.FileDialog(msoFileDialogFolderPicker) xSFileDlg.Title = " Please select the original folder:" If xSFileDlg.Show <> -1 Then Exit Sub xSPathStr = xSFileDlg.SelectedItems.Item(1) & "\" Set xDFileDlg = Application.FileDialog(msoFileDialogFolderPicker) xDFileDlg.Title = " Please select the destination folder:" If xDFileDlg.Show <> -1 Then Exit Sub xDPathStr = xDFileDlg.SelectedItems.Item(1) & "\" For Each xCell In xRg xVal = xCell.Value If TypeName(xVal) = "String" And xVal <> "" Then FileCopy xSPathStr & xVal, xDPathStr & xVal Kill xSPathStr & xVal End If Next End Sub
End Result: I'll be able to easily move large batches of files from one place to another that all might have a Julian date of "19091" (April 1, 2019).
link to sample included below:
[FONT="Helvetica"]GO TO FILE [/FONT]