Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copying from variable named sheet...


Below is code that I found on a site by Ron De Bruin. It seems to work
well for what I am asking it to, but I am curious if there is a way to
speed it up. The folder that it is pulling information from has
several hundred files and it takes a great deal of time. I'm not sure
if perhaps I do not have the right code for this type of process or if
there is anything I can do other than sit and wait for it to update.
Also I was wondering if there is a way to modify it to only update new
files.... Help is 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 Sub


--
shikamikamoomoo
------------------------------------------------------------------------
shikamikamoomoo's Profile: http://www.excelforum.com/member.php...o&userid=21018
View this thread: http://www.excelforum.com/showthread...hreadid=525078

Reply
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
supress prompt for named ranges when copying sheet to new workbook neowok[_86_] Excel Programming 1 February 1st 06 05:53 PM
Copying named ranges from one sheet to another Mark Stephens Excel Programming 3 August 4th 05 02:54 PM
Macro for copying named range to any sheet Cutter[_6_] Excel Programming 6 July 2nd 04 11:03 PM
Can A Named Range Be A Variable? Minitman[_2_] Excel Programming 7 February 25th 04 11:41 PM
Copying an array variable to a sheet M Rose Excel Programming 0 July 14th 03 12:04 AM


All times are GMT +1. The time now is 09:08 AM.

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

About Us

"It's about Microsoft Excel"