Hello EarlD,
I partially rewrote your macro and tested it. This will copy the information over from the imported workbook to the template.
Sub FileToImport()
Dim chkOKFileName As Boolean
Dim fImport As Variant
Dim fnImport As String
Dim fnTemplate As String
Dim fnNewName As String
Dim WksImport As Worksheet
Dim WksMain As Worksheet
Set WksMain = ThisWorkbook.Worksheets("Sheet1")
fImport = Application.GetOpenFilename("Excel-files,*.xls", 1, "Select File To Import", , False)
fnImport = GetFileName(CStr(fImport))
fnTemplate = "Factory Master Packing List.xls"
If TypeName(fImport) = "Boolean" Then
'the user didn't select a file
MsgBox ("File was NOT selected for import!")
Exit Sub
End If
'Assign Import Worksheet to an Object variable
Workbooks.Open fImport
Set WksImport = ActiveWorkbook.Sheets(1)
'Order ID Number
WksMain.Range("A12") = WksImport.Range("A4")
'Order Date
WksMain.Range("E12") = WksImport.Range("B4")
'Delivery Service
WksMain.Range("G12") = WksImport.Range("C4")
'Store Location
WksMain.Range("A14") = WksImport.Range("B7")
'Store
WksMain.Range("A15") = WksImport.Range("B8")
'Adress 1
WksMain.Range("A16") = WksImport.Range("B10")
'Address 2
WksMain.Range("A17") = WksImport.Range("B11")
'Address 3
WksMain.Range("A18") = WksImport.Range("B12")
'Address 4
WksMain.Range("A19") = WksImport.Range("B13")
'Address 5
WksMain.Range("A20") = WksImport.Range("B14")
'Address 6
WksMain.Range("A21") = WksImport.Range("B15")
'Close the Import Workbook - Don't Save Changes
WksImport.Parent.Close savechanges:=False
WksMain.Parent.Activate
Range("C5").Select
'Rmeove All Macros
Set VBComps = ActiveWorkbook.VBProject.VBComponents
For Each VBComp In VBComps
Select Case VBComp.Type
Case vbext_ct_StdModule, vbext_ct_MSForm, vbext_ct_ClassModule
VBComps.Remove VBComp
Case Else
With VBComp.CodeModule
.DeleteLines 1, .CountOfLines
End With
End Select
Next VBComp
'Delete "Import" Sheet and prompt for new file name
Call DeleteSheet("IMPORT")
chkOKFileName = Application.Dialogs(xlDialogSaveAs).Show("Enter new file name here")
'Save the new workbook
If chkOKFileName = True Then
fnNewName = ActiveWorkbook.Name
Else
MsgBox ("File was NOT saved!")
End If
End Sub
Bookmarks