That looks bad...try again:
'Starting row on source worksheet
StartRow = 11
'Get the workbooks to open
xlsFiles = Application.GetOpenFilename(FileFilter:="Excel files (*.xls), *.xls", MultiSelect:=True)
If VarType(xlsFiles) = vbBoolean Then Exit Sub
'Loop through each workbook and copy the data to this workbook
For Each wkbname In xlsFiles
Set SrcWkb = Workbooks.Open(FileName:=wkbname, ReadOnly:=True)
LastRow = SrcWkb.Worksheets("Data").Cells(Rows.Count, "BG").End(xlUp).Row
If LastRow >= StartRow Then
With SrcWkb.Worksheets("Data")
DstWks1.Cells(R, C).Resize(LastRow - StartRow + 1, 1).Value = _
.Range(.Cells(StartRow, "BG"), .Cells(LastRow, "BG")).Value
End With
End If
LastRow = SrcWkb.Worksheets("Data").Cells(Rows.Count, "CB").End(xlUp).Row
If LastRow >= StartRow Then
With SrcWkb.Worksheets("Data")
DstWks2.Cells(R, C).Resize(LastRow - StartRow + 1, 1).Value = _
.Range(.Cells(StartRow, "CG"), .Cells(LastRow, "CG")).Value
End With
End If
C = C + 1
SrcWkb.Close
Next wkbname
End Sub
|