Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Joe Joe is offline
external usenet poster
 
Posts: 476
Default Extract workbook information

I want to programmically extract certain information from all workbooks in a
folder, always in the same place on the same sheet in each workbook.

The result will look like this:

Bookname Sales Profit
Book1 999 999
Book2 999 999
etc.

assuming Sales and Profit are in cells c10 and g10 of the sheet named "P&L".
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,522
Default Extract workbook information

One way. Set up formulas like this in col b and col c for an already known
file name. Then have a list of the files in col a and use the macro to
change all.

=[MENU.xls]Off2007!$a$2

Sub changefilenames()
For Each c In Range("h6:h7")
c.Replace "ok", c.Offset(, -1)
Next c
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Joe" wrote in message
...
I want to programmically extract certain information from all workbooks in
a
folder, always in the same place on the same sheet in each workbook.

The result will look like this:

Bookname Sales Profit
Book1 999 999
Book2 999 999
etc.

assuming Sales and Profit are in cells c10 and g10 of the sheet named
"P&L".


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Extract workbook information

Joe,

This assumes every file in the directory you choose will have a sheet called
P&L.

Sub LoopThroughDirectory()
Application.DisplayAlerts = False
'Change this to your directory
MyPath = "C:\"
ActiveFile = Dir(MyPath & "*.xls")
Do While ActiveFile < ""
Workbooks.Open Filename:=MyPath & ActiveFile
BkName = ActiveWorkbook.Name
ActiveWorkbook.Sheets("P&L").Range("C10,G10").Copy
ActiveWorkbook.Close False
lastrow = ThisWorkbook.Sheets("Sheet1").Cells(Cells.Rows.Cou nt,
"A").End(xlUp).Row + 1
ThisWorkbook.Sheets("Sheet1").Cells(lastrow, 1) = BkName
ThisWorkbook.Sheets("Sheet1").Cells(lastrow, 1).Offset(, 1).PasteSpecial

ActiveFile = Dir()
Loop
Application.DisplayAlerts = True
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Joe" wrote:

I want to programmically extract certain information from all workbooks in a
folder, always in the same place on the same sheet in each workbook.

The result will look like this:

Bookname Sales Profit
Book1 999 999
Book2 999 999
etc.

assuming Sales and Profit are in cells c10 and g10 of the sheet named "P&L".

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default Extract workbook information

Try some code like the following:


Sub AAA()
Dim Dest As Range
Dim FName As String
Dim Path As String
Dim WB As Workbook
Dim WS As Worksheet

Set Dest = ThisWorkbook.Worksheets("Sheet1").Range("A1") '<<<
CHANGE
Path = "D:\Temp" '<<< CHANGE
ChDrive Path
ChDir Path
FName = Dir("*.xls")
Do Until FName = vbNullString
Set WB = Workbooks.Open(Filename:=FName)
Set WS = WB.Worksheets("P&L")
Dest(1, 1).Value = WB.Name
Dest(1, 2).Value = WS.Range("C10")
Dest(1, 3).Value = WS.Range("G10")
Set Dest = Dest(2, 1)
WB.Close savechanges:=False
FName = Dir()
Loop
End Sub

Change the lines marked with '<<< to meet your needs. Dest is the cell
at which the list of extracted values will begin. Path is the folder
name that conatins the workbooks whose contents you want to extract.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com




On Thu, 20 May 2010 06:59:02 -0700, Joe
wrote:

I want to programmically extract certain information from all workbooks in a
folder, always in the same place on the same sheet in each workbook.

The result will look like this:

Bookname Sales Profit
Book1 999 999
Book2 999 999
etc.

assuming Sales and Profit are in cells c10 and g10 of the sheet named "P&L".

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
how to extract information from one table to another one Omics Excel Discussion (Misc queries) 5 June 13th 08 10:06 PM
Extract Information to another worksheet Woo Excel Worksheet Functions 4 August 13th 07 08:36 PM
Extract information from the list 0-0 Wai Wai ^-^ Excel Worksheet Functions 3 May 12th 06 11:57 AM
Extract information from worksheet bbc1 Excel Discussion (Misc queries) 0 April 5th 06 06:52 AM
Please help: Extract some information from a cell Bobsus5 Excel Discussion (Misc queries) 2 March 7th 06 04:11 AM


All times are GMT +1. The time now is 04:44 PM.

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"