[Solved] Copy data from Multiple files in a Folder and Update

Dear,

I have certain files in a folder with data; Each file has a certain date and hourly data. My objective is to collect all the data from all the files and merge into a "Plant Record File".

Plant Record File has datewise complete data which is copied from each file when Clicked on UPDATE button. When ever, i click on UPDATE button, it checks upto which date data is copied, in case any new file comes to the folder and i click on UPDATE button, it only takes data of this new file.

It looks to very tough to me; kindly help me to solve the issue. (Files are attached)
 

Attachments

  • DCS_READING_18Apr2023060013.xlsx
    129.2 KB · Views: 2
  • DCS_READING_19Apr2023060002.xlsx
    130 KB · Views: 2
  • Plant Record.xlsx
    32 KB · Views: 2
Dear,

I have certain files in a folder with data; Each file has a certain date and hourly data. My objective is to collect all the data from all the files and merge into a "Plant Record File".

Plant Record File has datewise complete data which is copied from each file when Clicked on UPDATE button. When ever, i click on UPDATE button, it checks upto which date data is copied, in case any new file comes to the folder and i click on UPDATE button, it only takes data of this new file.

It looks to very tough to me; kindly help me to solve the issue. (Files are attached)
Dear Faisal,

Glad to hear from you again. Thank you for the thorough explanation of the problem. I understand you wish to copy data from multiple files in a folder and update it.

I would recommend using the below VBA code. It imports data from files located in a specific folder and moves the imported files to an archive folder. Don't forget to modify the code if necessary. The VBA code:
Code:
Sub Import_Data()
    Dim sPath As String
    Dim sFile As String
    Dim sArchive As String

    sPath = "X:\Importfiles\"
    sArchive = "X:\Importfiles\Archive\"
  
    sFile = Dir(sPath & "*.*")
    Do While sFile > vbNullString
        
        Name sPath & sFile As sArchive & "\" & sFile
        sFile = Dir
    Loop
End Sub
Further, if you wish to expand your project and open all the Excel files in a folder and copy data, go to this article https://www.exceldemy.com/open-all-excel-files-in-a-folder-and-copy-data-using-vba/.

Regards,
Yousuf Shovon
 

Online statistics

Members online
0
Guests online
10
Total visitors
10

Forum statistics

Threads
292
Messages
1,268
Members
531
Latest member
lonkfps
Top