C
Corrie
I'm creating a tool that will be used by multiple users. Although the
external data will be same, the users may save it differently. I
thought I would use GetOpenFileName so that the user would select there
own file. However, I don't know how to close the file once the data
has been copied and pasted into "Daily DL" tab. I am using the
following code but it locks up... Any ideas?
Sub ImportDaily()
Dim WorkbookName As String
Dim FileToOpen As String
Dim WorkbookName1 As String
Sheets("Daily DL").Select
Cells.Select
Selection.Clear
Selection.FormatConditions.Delete
Selection.Interior.ColorIndex = xlNone
Range("A1").Select
WorkbookName = Range("A1").Parent.Parent.Name
MsgBox "Please select the file with the Daily Route data you wish
to import."
FileToOpen = Application _
.GetOpenFilename("excel(*.xls), *.xls")
If FileToOpen = "False" Then
End If
Workbooks.Open Filename:=FileToOpen
Range("A1").Select
WorkbookName1 = Range("A1").Parent.Parent.Name
Cells.Select
Selection.Copy
Windows(WorkbookName).Activate
Range("A1").Select
ActiveSheet.Paste
Windows(WorkbookName1).Close
Windows(WorkbookName).Activate
Range("A1").Select
external data will be same, the users may save it differently. I
thought I would use GetOpenFileName so that the user would select there
own file. However, I don't know how to close the file once the data
has been copied and pasted into "Daily DL" tab. I am using the
following code but it locks up... Any ideas?
Sub ImportDaily()
Dim WorkbookName As String
Dim FileToOpen As String
Dim WorkbookName1 As String
Sheets("Daily DL").Select
Cells.Select
Selection.Clear
Selection.FormatConditions.Delete
Selection.Interior.ColorIndex = xlNone
Range("A1").Select
WorkbookName = Range("A1").Parent.Parent.Name
MsgBox "Please select the file with the Daily Route data you wish
to import."
FileToOpen = Application _
.GetOpenFilename("excel(*.xls), *.xls")
If FileToOpen = "False" Then
End If
Workbooks.Open Filename:=FileToOpen
Range("A1").Select
WorkbookName1 = Range("A1").Parent.Parent.Name
Cells.Select
Selection.Copy
Windows(WorkbookName).Activate
Range("A1").Select
ActiveSheet.Paste
Windows(WorkbookName1).Close
Windows(WorkbookName).Activate
Range("A1").Select