VBA Challenge - my programming skills are rusty!

swcaputo

New Member
Joined
Nov 4, 2003
Messages
37
I need to extract data from a directory called: C:\2010 Performance Review
here's the parameters...
1. There are an unknown number of files in the directory.

2. The files have unknown names.

3. The files - have the same structure as far as sheet names etc... (it's just the names that are different and unknown)

4. The data must be extracted without opening the files (each file is about 7 mb so too slow to open each one....)- there is total of 5 different pieces of information I need from each file.

5. It has to work with both excel 2003 and 2007 - so I can't use Application.FileSearch :(

6. The data when extracted will look like:
File name1 Data1 Data2 Data 3 Data 4 Data5
File name2 Data1 Data2 Data 3 Data 4 Data5
File name3 Data1 Data2 Data 3 Data 4 Data5
File name4 Data1 Data2 Data 3 Data 4 Data5
etc...

7. A nice to have.... would be to then email the data collected in #6 to someone.

I had created this a few years ago...with help from this forum... and it worked with excel 2003 (it didn't have the email idea that's in #7)

I now need to get it to work with 2003 and 2007.

The problem is that my programming skills have gone way down.... :(

Thank so much for everyone's help in advance.

Here's the old code...

Private Sub Worksheet_Activate()

Range("A3").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ClearContents

Dim sdir, fdir As String
On Error Resume Next
Application.ScreenUpdating = False

Set fs = Application.FileSearch

With fs
sdir = "C:\2010 Performance Review"
.LookIn = sdir
.Filename = ".xls"

If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
'Range("a" & i).Hyperlinks.Add Anchor:=Range("a" & i), _
Address:=.FoundFiles(i)
fdir = .FoundFiles(i)
Range("a" & i + 2).Formula = Right(fdir, Len(fdir) - Len(sdir) - 1)
Range("b" & i + 2).Formula = "='" & sdir & "\[" & Right(fdir, Len(fdir) - Len(sdir) - 1) & "]Answer Questions'!c146"
Range("c" & i + 2).Formula = "='" & sdir & "\[" & Right(fdir, Len(fdir) - Len(sdir) - 1) & "]Answer Questions'!c147"
Range("d" & i + 2).Formula = "='" & sdir & "\[" & Right(fdir, Len(fdir) - Len(sdir) - 1) & "]Answer Questions'!c148"
Range("e" & i + 2).Formula = "='" & sdir & "\[" & Right(fdir, Len(fdir) - Len(sdir) - 1) & "]Answer Questions'!c149"
Range("f" & i + 2).Formula = "='" & sdir & "\[" & Right(fdir, Len(fdir) - Len(sdir) - 1) & "]Answer Questions'!c145"

Next i
End If
End With

Application.ScreenUpdating = True

Columns("A:A").Select
Selection.Columns.AutoFit
Selection.Font.ColorIndex = 0
Columns("C:C").Select
Selection.NumberFormat = "0.00"

Range("A3").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Can't anyone help with rusty programming skills?
Any and all help is greatly appreciated!
Thanks!
:)
 
Upvote 0

Forum statistics

Threads
1,215,775
Messages
6,126,826
Members
449,341
Latest member
addman24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top