Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-23-2018, 11:28 AM
Vivianweir Vivianweir is offline Need help fixing compile error expected End Sub to combine multiple documents into one (Mac) Mac OS X Need help fixing compile error expected End Sub to combine multiple documents into one (Mac) Office 2011 for Mac
Novice
Need help fixing compile error expected End Sub to combine multiple documents into one (Mac)
 
Join Date: Oct 2018
Posts: 2
Vivianweir is on a distinguished road
Exclamation Need help fixing compile error expected End Sub to combine multiple documents into one (Mac)

I would like to combine multiple excel files into one. I was referred to trumpexcel.com. I entered the following and get a compile error: expected End Sub. How do I fix it? Is trumpexcel legit? If not what is the right verbiage to use?
Code:
Sub ConslidateWorkbooks()
'Created by Sumit Bansal from https://trumpexcel.com
Dim FolderPath As String
Dim Filename As String
Dim Sheet As Worksheet
Application.ScreenUpdating = False
FolderPath = Environ("userprofile") & "\Desktop\files to merge\"
Filename = Dir(FolderPath & "*.xls*")
Do While Filename <> ""
  Workbooks.Open Filename:=FolderPath & Filename, ReadOnly:=True
  For Each Sheet In ActiveWorkbook.Sheets
    Sheet.Copy After:=ThisWorkbook.Sheets(1)
  Next Sheet
  Workbooks(Filename).Close
  Filename = Dir()
Loop
Application.ScreenUpdating = True
End Sub
Thank you!!!

Last edited by Pecoflyer; 10-24-2018 at 11:19 PM. Reason: Added code tags & repaired formatting (macropod) + added Mac to title
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
compile error expected end sub ashg75 Word VBA 2 07-13-2017 07:08 AM
Need help fixing compile error expected End Sub to combine multiple documents into one (Mac) best approach to combine documents being created by multiple users jwalke123 Word 5 08-08-2015 03:27 PM
Need help fixing compile error expected End Sub to combine multiple documents into one (Mac) Compile error in Module ksigcajun Word VBA 2 04-08-2015 06:44 AM
Cross-referencing in multiple documents that will combine to make one report razberri Word 1 01-20-2014 01:00 AM
combine multiple documents word starter 2010 bribelge Word 3 12-19-2012 09:25 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:20 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft