Function ImportData(fileIn As Variant)
'Purpose: Import data from source file selected into this file. remove duplciate information
' on dropdown tabs.
' Enhancements needed:
' 1. Verify the format of the source workbook to ensure that it is in the same format.
'Application.ScreenUpdating = False
' This workbook
Dim a As Workbook
' Source Workbook
Dim b As Workbook
Dim ca As Range
Dim cb As Range
Dim wsx As Worksheet
Dim ur As Range
Dim sr As String
'file = FunctionGetFileName(file)
'If Not IsFileOpen(file) Then
Set a = ThisWorkbook
'Application.Workbooks.Open file
'Else
Set b = Workbooks.Open(fileIn) 'Workbooks(file)
With b
' Make all worksheets visibile
For Each wsx In b.Worksheets
wsx.Visible = True
Next wsx
End With
b.Sheets("detail").Activate
' Remove header row from range.
Set cb = Range("Page").Offset(1, 0).Resize(Range("Page").Rows.Count - 1, Range("Page").Columns.Count)
'Range("Page").Select
cb.Select
Selection.Copy
' Now handle the Detail tab by appending to existing data
' How to handle large amount of data on clipboard?
' Need to use another method besides copy to clipboard especially for large amount of data. Maybe
' row by row?
' Consider using Detailsource range as input
a.Sheets("Detail").Activate
Dim lc As Integer
' Try going to next row of Page Range.
lc = Range("Page").Row + Range("Page").Rows.Count
Cells(lc, 2).Select
'Set cb = Range("Page").Offset(1, 0).Resize(Range("Page").Rows.Count - 1, Range("Page").Columns.Count)
'Range("Page").Select
'cb.Select
ActiveSheet.Paste
'Selection.Paste
'Cells(lc, 2).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Detail").Activate
Application.CutCopyMode = False
Application.ScreenUpdating = True
b.Close (False)
'End If
End Function
|