View Single Post
 
Old 05-11-2018, 11:13 PM
Shashi Kant Shashi Kant is offline Windows 7 32bit Office 2016
Novice
 
Join Date: May 2018
Posts: 16
Shashi Kant is on a distinguished road
Default Find a possible solution

Code:
Option Explicit
Option Base 1

Private Sub CommandButton1_Click()
    Application.ScreenUpdating = False
    
    Dim wkb As Workbook
    Dim i As Integer
    Dim wbName(5) As String
    
    wbName(1) = "Car.xlsx"
    wbName(2) = "Bikes.xlsx"
    wbName(3) = "HGV.xlsx"
    wbName(4) = "Vans.xlsx"
    wbName(5) = "Other.xlsx"
    
    For i = 1 To 5
        Set wkb = Workbooks.Open(ThisWorkbook.Path & "\" & wbName(i))
    
        wkb.Worksheets(1).Range("A1").CurrentRegion.Offset(1, 0).Select
        Selection.Resize(Selection.Rows.Count - 1).Select
    
        Selection.Copy ThisWorkbook.Worksheets(i).Range("A2")
        wkb.Close savechanges:=True
    Next i
    Application.ScreenUpdating = True
End Sub

Last edited by Shashi Kant; 05-12-2018 at 05:09 AM.
Reply With Quote