LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Open external data (varying file names) and closing file once data is retrieved

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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I import text file, analyze data, export results, open next file Geoffro Excel Programming 2 March 6th 05 08:02 PM
How do I reference external data from a file, file name found in . Clux Excel Discussion (Misc queries) 1 February 10th 05 10:52 PM
Refreshing External Data on File Open grubstar Excel Programming 3 September 21st 04 05:25 PM
Updating Data Retrieved from an HTML file Mark[_22_] Excel Programming 0 December 4th 03 12:30 AM
Get External Data, Import Text File, File name problem Scott Riddle Excel Programming 1 July 11th 03 05:40 PM


All times are GMT +1. The time now is 06:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"