Thursday, 17 January 2013

How to Create a Dialog Box To Select and Merge Multiple Workbooks into Main Workbook

Excel VBA Macro to Open Dialog Box To Select and Merge Multiple Workbooks into Target Workbook
'This is Very User Friendly Macro that allows you to Merge Multiple Workbooks Selected from a open Dialog Box Into Our Workbook'

Sub CombineWorkbooks()

    Dim FilesToOpen As Variant
    Dim X As Integer

    On Error GoTo ErrHandler

    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

    FilesToOpen = Application.GetOpenFilename
 (FileFilter:="Microsoft Excel Files (*.xls*), *.xls*",MultiSelect:=True, Title:="Files to Merge")

    If TypeName(FilesToOpen) = "Boolean" Then

        MsgBox "No Files Were Selected"
        GoTo ExitHandler
    End If

   X = 1

    While X <= UBound(FilesToOpen)
        Workbooks.Open Filename:=FilesToOpen(x)
        Sheets().Move After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
        + 1
    Application.ScreenUpdating = True
    Exit Sub


    MsgBox Err.Description, vbCritical, "Error"
    Resume ExitHandler
End Sub


1 comment:

  1. What a stuff of un-ambiguity and preserveness
    of valuable knowledge about unexpected emotions.


Hi User, Thank You for visiting My Blog. Please post your open Feedback only related to this Blog Posts. Please note that I cannot respond to the Anonymous Comments.

Subscribe to Blog Posts by Email

ExcelKingdom-Popular Posts