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 Extracting Data - Open vs Closed


Hi,

I've got 20 spreadsheets called Week 1 to Week 20 each has two sheets
called Wk 42 T and Week 42 R. They are stored in a shared area on the K
Drive. I want to copy all the data from Column M in both sheets (around
180 to 200 lines) and then transfer the data to a workbook called
"summary" with two sheets called "Totals T" & "Total R".

I've was thinking of using the below code to open the workbooks but is
this the best way??.

If it is the best way I need help with selecting the data from the
Workbooks called Week 1 to Week 20 in the K drive and then looping
through each workbook and the two worksheets and pasting that data in
Column A in "Totals T" (all info from Wk 42 T) & "Total R" (all info
from Wk 42 R) in the workbook called "Summary"

Any help greatly appreciated



Code:
--------------------

Sub RunCodeOnAllXLSFiles()
Dim lCount As Long
Dim wbResults As Workbook
Dim wbCodeBook As Workbook

Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False

On Error Resume Next

Set wbCodeBook = ThisWorkbook

With Application.FileSearch
.NewSearch
'Change path to suit
.LookIn = "C:\MyDocuments\TestResults"
.FileType = msoFileTypeExcelWorkbooks
'.Filename = "Book*.xls"

If .Execute 0 Then 'Workbooks in folder
For lCount = 1 To .FoundFiles.Count 'Loop through all.
'Open Workbook x and Set a Workbook variable to it
Set wbResults = Workbooks.Open(Filename:=.FoundFiles(lCount), UpdateLinks:=0)

'CODE HERE

wbResults.Close SaveChanges:=True

Next lCount
End If
End With

On Error Goto 0
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub

--------------------



Thanks

VBA Noob


--
VBA Noob
------------------------------------------------------------------------
VBA Noob's Profile: http://www.excelforum.com/member.php...o&userid=33833
View this thread: http://www.excelforum.com/showthread...hreadid=551766

 
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 to: Open closed workbook/Search data tables/Return data to open workbook Hugh Adams Excel Discussion (Misc queries) 0 August 18th 10 02:04 PM
Day Counting - OPEN & CLOSED Dax Arroway Excel Worksheet Functions 9 November 3rd 08 07:46 PM
Move entire row of data from open to closed file by entering date TB[_2_] Excel Discussion (Misc queries) 0 May 12th 08 10:07 PM
Extracting data from a closed workbook Barb Reinhardt Excel Programming 2 February 7th 06 02:47 PM
Open a closed workbook with VBA ttomlinson Excel Programming 0 May 29th 05 04:39 PM


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