• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Error Prompt while running Vba code

Hi Team,

While trying to run the below code ..I am getting the below prompts every time i run it.
The below screens appear for multiple times say for example as many as Excel files we have stored in - ("C:\Users\user33\Documents\Merge")

Where am I doing wrong???

Apprecaite your help.

Note : The code generally merges all the files in ("C:\Users\user33\Documents\Merge") in one consolidated File.
But if I have 100 files to be run then the below screens are getting prompted 100 times.

Upon pressing 100 times "Yes" and 100 times "save" the desired output is being reflected.

Any workaround to avoid the below Prompts.


upload_2017-8-28_23-18-19.png


upload_2017-8-28_23-19-37.png




Code:
Sub simpleXlsMerger()
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:\Users\user33\Documents\Merge")
Set filesObj = dirObj.Files
For Each everyObj In filesObj
Set topform = Workbooks.Open(everyObj)
'change "A2" with cell reference of start point for every files here
'for example "B3:IV" to merge all files start from columns B and rows 3
'If you're files using more than IV column, change it to the latest column
'Also change "A" column on "A65536" to the same column as start point
Range("A2:V" & Range("A65536").End(xlUp).Row).Copy
ThisWorkbook.Worksheets(1).Activate
'Do not change the following column. It's not the same column as above
Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial
Application.CutCopyMode = False
topform.Close
Next
End Sub
 

Attachments

  • upload_2017-8-28_23-20-3.png
    upload_2017-8-28_23-20-3.png
    8 KB · Views: 3
Back
Top