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: 1
Default Way to only import new files?


Below is code that I found on a site by Ron De Bruin. It seems to wor
well for what I am asking it to, but I am curious if there is a way t
speed it up. The folder that it is pulling information from has severa
hundred files and it takes a great deal of time. I'm not sure if perhap
I do not have the right code for this type of process or if there i
anything I can do other than sit and wait for it to update. Or I wa
wondering if there is a way to modify it to only update new files an
paste the information at the next available blank line.... Help i
appreciated. Thanks!

Sub Example1()
Dim basebook As Workbook
Dim mybook As Workbook
Dim rnum As Long
Dim FNames As String
Dim MyPath As String
Dim SaveDriveDir As String
Dim Cnum As Integer
Dim cell As Range


SaveDriveDir = CurDir
MyPath = "C:\Documents and Settings...."
ChDrive MyPath
ChDir MyPath

FNames = Dir("*.xls")
If Len(FNames) = 0 Then
MsgBox "No files in the Directory"
ChDrive SaveDriveDir
ChDir SaveDriveDir
Exit Sub
End If

Application.ScreenUpdating = False
Set basebook = ThisWorkbook
'clear all cells on the first sheet
'basebook.Worksheets(1).Cells.Clear

rnum = 2

Do While FNames < ""
Set mybook = Workbooks.Open(FNames)

Cnum = 1
For Each cell In mybook.Worksheets(1).Range("D4,I4,C6,D6")
basebook.Worksheets(1).Cells(rnum, Cnum).Value = cell.Value
Cnum = Cnum + 1
Next cell

mybook.Close False
rnum = rnum + 1
FNames = Dir()
Loop

ChDrive SaveDriveDir
ChDir SaveDriveDir
Application.ScreenUpdating = False
End Su

--
shikamikamoomo
-----------------------------------------------------------------------
shikamikamoomoo's Profile: http://www.excelforum.com/member.php...fo&userid=2101
View this thread: http://www.excelforum.com/showthread.php?threadid=52574

 
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
Import Several .txt Files Renee B. Excel Discussion (Misc queries) 2 October 3rd 07 07:06 PM
batch import dat files The Real Jd Excel Discussion (Misc queries) 2 February 16th 05 12:35 PM
Import files on a mac Andreas Roschger Excel Programming 5 February 1st 05 12:43 AM
import files Hollis Excel Programming 2 November 29th 04 08:27 PM
Import multiple files macro can't find files Steven Rosenberg Excel Programming 1 August 7th 03 01:47 AM


All times are GMT +1. The time now is 08:58 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"