Dinesh_Excel
Member
Hi Friends,
I have a folder in C drive (Temp) where in I have a file name called " Extract".
Now I was able to run the below code sucessfully where I had only one file in the Temp folder.
Need your help where the macro would select only the file name " Extract" and run the rest of the code.
Challenege : The code needs to pick file name " Extract" and ignore the rest of the files in temp folder, and run the rest of the code
Appreciate your help on the same.
I have a folder in C drive (Temp) where in I have a file name called " Extract".
Now I was able to run the below code sucessfully where I had only one file in the Temp folder.
Need your help where the macro would select only the file name " Extract" and run the rest of the code.
Challenege : The code needs to pick file name " Extract" and ignore the rest of the files in temp folder, and run the rest of the code
Appreciate your help on the same.
Sub simpleXlsMerger()
Worksheets("Base").Range("A2:G500").Select
Selection.ClearContents
Application.DisplayAlerts = False ' donot display alerts
Dim topform As Workbook
Dim mergeObj As Object, dirObj As Object, filesObj As Object, everyObj As Object
Application.ScreenUpdating = False
Set mergeObj = CreateObject("Scripting.FileSystemObject")
'change folder path of excel files here
Set dirObj = mergeObj.Getfolder("C:\temp")
Set filesObj = dirObj.Files
For Each everyObj In filesObj
Set topform = Workbooks.Open(everyObj)
Range("A2:V" & Range("A27000").End(xlUp).Row).Copy
ThisWorkbook.Worksheets(1).Activate
Range("A27000").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
topform.Close
Next
End Sub