View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick[_2_] Bernie Deitrick[_2_] is offline
external usenet poster
 
Posts: 176
Default External File Data Import

Adam,

If all your worksheets are in C:\Excel\Time Sheets, the sub below will copy the values in cells A1 and B1 (from the default
worksheet) of all the files into a new workbook. You can modify the code to get as many values as you need - or post back for help
in modifying it, if this is too simplistic for your needs.

HTH,
Bernie
Excel MVP


Sub ConsolidateSameDataFromAllFiles()
Dim myBook As Workbook
Dim i As Integer

Set myBook = Workbooks.Add

With Application.FileSearch
.NewSearch
'Change this to your directory
.LookIn = "C:\Excel\Time Sheets\"
.SearchSubFolders = False
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then
For i = 1 To .FoundFiles.Count
Workbooks.Open .FoundFiles(i)
myBook.Worksheets(1).Range("A65536").End(xlUp)(2). Value = _
ActiveWorkbook.Name
myBook.Worksheets(1).Range("B65536").End(xlUp)(2). Value = _
ActiveWorkbook.Worksheets(1).Range("A1").Value
myBook.Worksheets(1).Range("C65536").End(xlUp)(2). Value = _
ActiveWorkbook.Worksheets(1).Range("B1").Value
ActiveWorkbook.Close False
Next i
Else: MsgBox "There were no files found."
End If

End With

End Sub




"Adam Thickett" wrote in message ...
Hey Peeps,

I have a problem that i know can be easily solved if i
used MSAccess, but my manager won't spend any money.

I wish to import times from several time sheets into an
overall office timesheet. Each time sheet will have a
list of job numbers (e.g. X3456) with hours spent on each
listed next to it. I need to create a list of all the
different job numbers in the office timesheet with the
total number of hours spent on each by everyone in the
office.

I thought that a good way of doing it would be to get
everyone to save there timsheet in a certain folder.
Excel can then be told to import the info from certain
cells in each file in the folder. This will mean that as
more files are added excel will update??

I can program, but not very well in excel and this is past
me. Please can you help me :-)

If you need more info please don't hesitate to ask me, I
hope it makes sense?



Thanks in advance

Adam