Dave Smith
New Member
- Joined
- Jul 5, 2021
- Messages
- 32
- Office Version
- 2016
- Platform
- Windows
Hi,
A big thanks in advance,
I want to create a database using VBA code where I need to copy certain data from multiple excel file in to one excel file.
The user will enter the path of the folder where the multiple excel files are kept, and the code should copy following thing's from multiple excel in to one excel file:
1. file name
2. customer name
3. location
4. product name
5. date
I want to do this process in sequence like 1st enter the file name which is opened in master file, then copy specific cell value from the opened excel file & activate the master file and paste it.
2nd close the opened file open second file and repeat the copy paste procedure.
3rd after copying all the data from all the files present in the folder it should save the master database excel file
I have written the code to get file name from the folder in master data base file as shown below but i am not able to figuring out how to open that file copy and paste in this in sequence
Sub getfolderdfilenames()
Dim objFSO As Scripting.FileSystemObject
Dim objFolder As Scripting.Folder
Dim objfile As Scripting.File
Dim nextrow As Long
Set objFSO = CreateObject("Scripting.FilesystemObject")
Set objFolder = objFSO.GetFolder("C:\Users\SHMEHTA\Desktop\CFD Tool For Request")
nextrow = Database.Cells(Rows.Count, 1).End(xlUp).Row + 1
For Each objfile In objFolder.Files
Database.Cells(nextrow, 2) = objfile.Name
nextrow = nextrow + 1
Next objfile
End Sub
Any Help is appreciated plz....
Regards,
Dave
A big thanks in advance,
I want to create a database using VBA code where I need to copy certain data from multiple excel file in to one excel file.
The user will enter the path of the folder where the multiple excel files are kept, and the code should copy following thing's from multiple excel in to one excel file:
1. file name
2. customer name
3. location
4. product name
5. date
I want to do this process in sequence like 1st enter the file name which is opened in master file, then copy specific cell value from the opened excel file & activate the master file and paste it.
2nd close the opened file open second file and repeat the copy paste procedure.
3rd after copying all the data from all the files present in the folder it should save the master database excel file
I have written the code to get file name from the folder in master data base file as shown below but i am not able to figuring out how to open that file copy and paste in this in sequence
Sub getfolderdfilenames()
Dim objFSO As Scripting.FileSystemObject
Dim objFolder As Scripting.Folder
Dim objfile As Scripting.File
Dim nextrow As Long
Set objFSO = CreateObject("Scripting.FilesystemObject")
Set objFolder = objFSO.GetFolder("C:\Users\SHMEHTA\Desktop\CFD Tool For Request")
nextrow = Database.Cells(Rows.Count, 1).End(xlUp).Row + 1
For Each objfile In objFolder.Files
Database.Cells(nextrow, 2) = objfile.Name
nextrow = nextrow + 1
Next objfile
End Sub
Any Help is appreciated plz....
Regards,
Dave