Hello,
I'm trying to copy data from 5 different worksbooks into a single new workbook. The code is as follows:
My problem is with how to get the macro to copy the Row 1 which is present in all the 5 worksheets to appear on ONLY Row 1 in the new worksheet.
I'm trying to copy data from 5 different worksbooks into a single new workbook. The code is as follows:
Code:
Sub tiso()
Dim fn, e, wb As Workbook
fn = Application.GetOpenFilename(FileFilter:="Microsoft excel files (*.xls), *.xls", _
Title:="Press CTRL Key to Select Multiple Files", MultiSelect:=True)
If Not IsArray(fn) Then Exit Sub
Set wb = Workbooks.Add
wb.SaveAs Filename:="C:\tiso\compiled.xls"
For Each e In fn
With Workbooks.Open(e)
With .Sheets(1)
LastRow = Range("A65536").End(xlUp).Row
Range("A2", Cells(LastRow, "O")).Copy
wb.Sheets(1).Cells(wb.Sheets(1).Cells.SpecialCells(11).Row + 1, 1).PasteSpecial xlPasteValues
End With
.Close False
End With
Next
Application.CutCopyMode = False
Set wb = Nothing
End Sub
My problem is with how to get the macro to copy the Row 1 which is present in all the 5 worksheets to appear on ONLY Row 1 in the new worksheet.
Excel Workbook | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | |||
1 | Transaction Ref. | Debit Acct No | Debit Acct Name | Debit Currency | Debit Amount | Credit Their Ref | Credit Acct No | Credit Currency | COMMISSION.AMT | CHARGE.AMT | Amount Debited | Amount Credited | Local Amount Debited | Local Amt Credited | Processing Date | ||
Sheet1 |