Demo entry 6881456

Excel Consultor


Submitted by W on Sep 11, 2019 at 03:25
Language: VBScript. Code size: 1.6 kB.

Sub Open_Files()

Dim Hoja As Object

    Application.ScreenUpdating = False

       'Definir la variable como tipo Variante

       Dim X As Variant

       'Abrir cuadro de dialogo

       X = Application.GetOpenFilename _

           ("Excel Files (*.xlsx), *.xlsx)", 2, "Abrir archivos", , True)

    'Validar si se seleccionaron archivos

        If IsArray(X) Then ' Si se seleccionan

          'Crea Libro nuevo


          'Captura nombre de archivo destino donde se grabaran los archivos seleccionados

           A = ActiveWorkbook.Name



       For y = LBound(X) To UBound(X)

       Application.StatusBar = "Importando Archivos: " & X(y)

         Workbooks.Open X(y)

         b = ActiveWorkbook.Name

           For Each Hoja In ActiveWorkbook.Sheets

            Hoja.Copy after:=Workbooks(A).Sheets(Workbooks(A).Sheets.Count)


           Workbooks(b).Close False


       Application.StatusBar = "Listo"

       Call Unir_Hojas

    End If

    Application.ScreenUpdating = False

   End Sub

Sub Unir_Hojas()

Dim Sig As Byte, Eliminar As Boolean

    For Sig = 2 To Worksheets.Count

        Worksheets(Sig).UsedRange.Copy _



       Application.DisplayAlerts = False


    For Sig = 2 To Worksheets.Count



Application.DisplayAlerts = True

End Sub

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).