I was able to get some of this to work, however if I run the macro and it
filters a sheet with no data in column D, then I get an error and it stops.
Any way to fix this?
Also when it copies to the blank sheet, it copies all the formulas, etc. I
would like to paste any data picked up on the filter into the blank sheet as
special and give me only the values and the formating that it has on the
original sheet.
> >I have about 10 workbooks all setup the same with the same formating,
> >formulas, etc. but all with different data. Lets say they are called
[quoted text clipped - 73 lines]
> Grappenhall, Cheshire, UK
> __________________________
Richard Buttrey - 18 Aug 2006 18:28 GMT
Hi,
Try this slight modification
HTH.
Sub ExtractDateRecords()
Dim oFSO
Dim myFolder As Object
Dim Files As Object
Dim file As Object
Dim fldr
Dim Mydate As String
Dim MyWb As Workbook
Dim Tempwb As Workbook
Dim stTopCell As String
Application.DisplayAlerts = False
Set MyWb = ActiveWorkbook
Mydate = Range("mydate")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set myFolder = oFSO.GetFolder(Range("Myfolder"))
For Each file In myFolder.Files
If Left(file.Name, 8) = "Workbook" Then
Workbooks.Open Filename:=file.Path
Set Tempwb = ActiveWorkbook
Range("D1").AutoFilter Field:=4, Criteria1:="<=" & Mydate
If Range("d1").Offset(1, 0) <> "" Then
Range("D1").CurrentRegion.Offset(1,0).SpecialCells(xlCellTypeVisible).Copy
MyWb.Activate
stTopCell = Range("a65536").End(xlUp).Offset(1,0).Address
Range(stTopCell).PasteSpecial (xlPasteAll)
Range(stTopCell).PasteSpecial (xlPasteValues)
End If
Tempwb.Close
End If
Next file
Set oFSO = Nothing
End Sub
>I was able to get some of this to work, however if I run the macro and it
>filters a sheet with no data in column D, then I get an error and it stops.
[quoted text clipped - 81 lines]
>> Grappenhall, Cheshire, UK
>> __________________________
__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________