Tuesday, March 1, 2016

VBA Excel find matching list files and copy to another folder [Anwsered]

VBA Excel find matching list files and copy to another folder

Hello,
 
I have a list of filenames (if the filename is "surface_10001_upper, only 10001 is mentioned) in the first row of an excel sheet.
The actual files are located in the folder c:\copyfrom.
I need to match and search for file names from my Column A to files
located in c:\copyfrom and the one that are found copy to c:\copyto folder using VBA code.
 
Can you help me in finding the solution.

Anwsers to the Problem VBA Excel find matching list files and copy to another folder

Download SmartPCFixer to Fix It (Free)

Hello,
 
I have a list of filenames (if the filename is "surface_10001_upper, only 10001 is mentioned) in the first row of an excel sheet.
The actual files are located in the folder c:\copyfrom.
I need to match and search for file names from my Column A to files
located in c:\copyfrom and the one that are found copy to c:\copyto folder using VBA code.
 
Can you help me in finding the solution.

Hi Prakash Devarasu,
you can try with this code after set up folder names and range.

Andrew.

---
Public Sub copyFiles()
Dim wsSource As Excel.Worksheet
Dim sCopyFrom As String, sCopyTo As String, sFileToCopy As String
Dim lFiles As Long, lLastSourceRow As Long
Dim rFileToMatch As Range
Dim vbFile As Variant

  On Error Resume Next

  '---------- set up your data here
  sCopyFrom = "C:\CopyFromFolder\"
  sCopyTo = "C:\CopyToFolder\"
  Set wsSource = ThisWorkbook.Sheets("Sheet1")
  rFileToMatch = wsSource.Range("A2:A100")        ' range with file names to copy

  For Each vbFile In rFileToMatch
    '---------- no file extension for files to copy!
    sFileToCopy = "surface_" & Trim$(vbFile) & "_upper"
    If (Len(Dir(sCopyFrom & sFileToCopy)) > 0) Then
      lFiles = lFiles + 1
      FileCopy sCopyFrom & sFileToCopy, sCopyTo & sFileToCopy
    End If
  Next

  Call MsgBox(lFiles & " files copied.", vbInformation, "Copy Files")
End Sub
---

If you failed to fix it, another option is to call Microsoft and walk through the process with a technician. To do this, dial "1-800-936-5700". Explain the error that you received and the steps in the update process during which it was displayed. The technician will be able to walk through the steps from getting a new product key to finishing the installation.

Recommended Method to Repair the Problem: VBA Excel find matching list files and copy to another folder:

 

 

How to Fix VBA Excel find matching list files and copy to another folder with SmartPCFixer?

1. You can Download Error Fixer here. Install it on your computer. When you open SmartPCFixer, it will perform a scan.

2. After the scan is finished, you can see the errors and problems which need to be fixed.

3. When the Fixing part is done, your computer has been speeded up and the errors have been removed


Related: my CD DVD burner does not burn Linked Excel Tables not Visible Menus Links not working in IE9 Links in Facebook don t work click and drag is not working in Outlook Web Access Microsoft Excel 2007 Excel Jump List Not Showing Recent Documents Windows 7 My home pc has windows vista my router is a Linksys WRT110 my laptop has windows 7 When I try to connect to the internet my laptop does not connect and it kicks thehome pc off the net WHY Help my laptop says it is not connected to the internet Macro not sorting all columns in worksheet My tiles on start screen will not open it tells me it cannot open with administrator and to open with another account What can I do my computer will not let me download internet explorer My Window 7 Ultimate N will not go into sleep mode on its own my paste does not work at all i cannot access my games i think i have a virus or bugs on my computer Network cable is unplugged msg AND wireless will not stay connected on Vista Live ca email is coming from one of my contacts and not me No Microsoft Word Starter 2010 opening Followed directions and now nothing What can I do Mouse cursor randomly turns into a big plus sign and does not act like a mouse cursor at all,A Complete List Of Commands In Word 2010's Equation Editor?,AMD Event Client Module,Anchoring A Watermark,Attach Any Document Or Photo Into Hotmail,APPCRASH VHStoDVD5Starter.exe
Read More: Troubleshooting:How can I find out about whether or not an unkown company is supposed to be on my P.C.,How to Fix Problem - \"mwlDaemon.exe-unable to locate component. Application failed to start because sysenv.dll not found. Reinstalling may fix the problem\"?,Unable to open an application. [Anwsered],[Solved] why when i click on anything on my desktop does it say unable to start correctly(0xc0000142),Troubleshooter of Error: Macro to split multiple reports so each is on its own tab,Error "There is a problem with this Windows Installer package. A program required for the install to complete could not be run. Contact your support personnel or package vendor.",Problem with the Lenovo easy capture Application,Internet Explorer 8 History Filter BUG (Windows 7 Enterprise x32 Trial),Since updating to Windows 8.1, unable to disable my logon password and make computer go into sleep.,I tried to shrink my D drive to increase C, but thereare two MRT.exe files which cannot be moved or deleted. What do I do?

No comments:

Post a Comment