Hello,<o
></o
>
Iam a fairly big VBA noob and have been searching many forums for an answer tomy problem. I am having an issue with the application.filesearch in 2003 notworking in 2007/2013. I was wondering if anybody could help me re-write thecode to work in Office 2013. The code is pretty basic. Any help would begreatly appreciated. I believe the "find files" is the only sectionthat needs updated. Thanks in advance for your help!<o
></o
>
SubDatabase() Dim fn, m, d, X, c<o
></o
>
IfDay(Now()) = 1 Then Select Case Month(Now() - 10) Case Is = 1 X ="January" Case Is = 2 X = "February" Case Is = 3 X ="March" Case Is = 4 X = "April" Case Is = 5 X ="May" Case Is = 6 X = "June" Case Is = 7 X ="July" Case Is = 8 X = "August" Case Is = 9 X ="September" Case Is = 10 X = "October" Case Is = 11 X ="November" Case Is = 12 X = "December" End Select<o
></o
>
ElseSelect Case Month(Now()) Case Is = 1 X = "January" Case Is = 2 X ="February" Case Is = 3 X = "March" Case Is = 4 X ="April" Case Is = 5 X = "May" Case Is = 6 X ="June" Case Is = 7 X = "July" Case Is = 8 X ="August" Case Is = 9 X = "September" Case Is = 10 X ="October" Case Is = 11 X = "November" Case Is = 12 X ="December" End Select End If<o
></o
>
Sheets("Database").Cells(45,1).Resize(65000, 15).ClearContents Sheets("Non Prod Database").Cells(30,1).Resize(65000, 5).ClearContents<o
></o
>
'''''''''''''''''''''''Find Files WithApplication.FileSearch .NewSearch .LookIn = "S:\Corr\Corr".SearchSubFolders = True .Filename = X .MatchTextExactly = True .FileType =msoFileTypeAllFiles If .Execute() > 0 Then'''''''Import Into Excel For i = 1 To.FoundFiles.Count<o
></o
>
fn = .FoundFiles(i)<o
></o
>
<o
> </o
>
Workbooks.OpenFilename:=fn, ReadOnly:=True<o
></o
>
fn = ActiveWorkbook.Name<o
></o
>
For d = 2 ToWorksheets.Count<o
></o
>
Sheets(d).Select<o
></o
>
Cells(5, 2).Select<o
></o
>
If Cells(5, 2) = "" And Cells(6, 11)= "" Then<o
></o
>
GoTo Nextd1<o
></o
>
End If<o
></o
>
ActiveSheet.Unprotect<o
></o
>
c = Cells(1,8).Value<o
></o
>
Selection.CurrentRegion.Select<o
></o
>
Selection.Offset(2,0).Resize(Selection.Rows.Count - (92 - c), Selection.Columns.Count - 3).Select<o
></o
>
Selection.Copy<o
></o
>
ThisWorkbook.Activate<o
></o
>
Sheets("Database").Activate<o
></o
>
Range("A45").Select<o
></o
>
IfRange("A45") = "" Or Range("A46") = ""Then<o
></o
>
ActiveCell.Offset(0,1).Select<o
></o
>
Else<o
></o
>
Selection.End(xlDown).Select<o
></o
>
ActiveCell.Offset(1, 1).Select<o
></o
>
End If<o
></o
>
Selection.PasteSpecial Paste:=xlValues<o
></o
>
Application.CutCopyMode = False<o
></o
>
Selection.Resize(Selection.Rows.Count + 1, 1).Offset(0, -1).Select<o
></o
>
Selection.Value =Workbooks(fn).Name<o
></o
>
Selection.Offset(Selection.Rows.Count - 1, 10).Resize(1, 1).Select<o
></o
>
Selection =Workbooks(fn).ActiveSheet.Cells(6, 11)<o
></o
>
Workbooks(fn).Activate<o
></o
>
Cells(12,11).Resize(35, 2).Select<o
></o
>
Selection.Copy<o
></o
>
ThisWorkbook.Activate<o
></o
>
Sheets("NonProd Database").Activate<o
></o
>
Range("A27").Select<o
></o
>
IfRange("A27") = "" Or Range("A28") = ""Then<o
></o
>
ActiveCell.Offset(0,1).Select<o
></o
>
Else<o
></o
>
Selection.End(xlDown).Select<o
></o
>
ActiveCell.Offset(1, 1).Select<o
></o
>
End If<o
></o
>
Selection.PasteSpecial Paste:=xlValues<o
></o
>
Application.CutCopyMode = False<o
></o
>
Selection.Resize(Selection.Rows.Count + 1, 1).Offset(0, -1).Select<o
></o
>
Selection.Value =Workbooks(fn).Name<o
></o
>
Workbooks(fn).Activate<o
></o
>
<o
> </o
>


Iam a fairly big VBA noob and have been searching many forums for an answer tomy problem. I am having an issue with the application.filesearch in 2003 notworking in 2007/2013. I was wondering if anybody could help me re-write thecode to work in Office 2013. The code is pretty basic. Any help would begreatly appreciated. I believe the "find files" is the only sectionthat needs updated. Thanks in advance for your help!<o


SubDatabase() Dim fn, m, d, X, c<o


IfDay(Now()) = 1 Then Select Case Month(Now() - 10) Case Is = 1 X ="January" Case Is = 2 X = "February" Case Is = 3 X ="March" Case Is = 4 X = "April" Case Is = 5 X ="May" Case Is = 6 X = "June" Case Is = 7 X ="July" Case Is = 8 X = "August" Case Is = 9 X ="September" Case Is = 10 X = "October" Case Is = 11 X ="November" Case Is = 12 X = "December" End Select<o


ElseSelect Case Month(Now()) Case Is = 1 X = "January" Case Is = 2 X ="February" Case Is = 3 X = "March" Case Is = 4 X ="April" Case Is = 5 X = "May" Case Is = 6 X ="June" Case Is = 7 X = "July" Case Is = 8 X ="August" Case Is = 9 X = "September" Case Is = 10 X ="October" Case Is = 11 X = "November" Case Is = 12 X ="December" End Select End If<o


Sheets("Database").Cells(45,1).Resize(65000, 15).ClearContents Sheets("Non Prod Database").Cells(30,1).Resize(65000, 5).ClearContents<o


'''''''''''''''''''''''Find Files WithApplication.FileSearch .NewSearch .LookIn = "S:\Corr\Corr".SearchSubFolders = True .Filename = X .MatchTextExactly = True .FileType =msoFileTypeAllFiles If .Execute() > 0 Then'''''''Import Into Excel For i = 1 To.FoundFiles.Count<o


fn = .FoundFiles(i)<o


<o


Workbooks.OpenFilename:=fn, ReadOnly:=True<o


fn = ActiveWorkbook.Name<o


For d = 2 ToWorksheets.Count<o


Sheets(d).Select<o


Cells(5, 2).Select<o


If Cells(5, 2) = "" And Cells(6, 11)= "" Then<o


GoTo Nextd1<o


End If<o


ActiveSheet.Unprotect<o


c = Cells(1,8).Value<o


Selection.CurrentRegion.Select<o


Selection.Offset(2,0).Resize(Selection.Rows.Count - (92 - c), Selection.Columns.Count - 3).Select<o


Selection.Copy<o


ThisWorkbook.Activate<o


Sheets("Database").Activate<o


Range("A45").Select<o


IfRange("A45") = "" Or Range("A46") = ""Then<o


ActiveCell.Offset(0,1).Select<o


Else<o


Selection.End(xlDown).Select<o


ActiveCell.Offset(1, 1).Select<o


End If<o


Selection.PasteSpecial Paste:=xlValues<o


Application.CutCopyMode = False<o


Selection.Resize(Selection.Rows.Count + 1, 1).Offset(0, -1).Select<o


Selection.Value =Workbooks(fn).Name<o


Selection.Offset(Selection.Rows.Count - 1, 10).Resize(1, 1).Select<o


Selection =Workbooks(fn).ActiveSheet.Cells(6, 11)<o


Workbooks(fn).Activate<o


Cells(12,11).Resize(35, 2).Select<o


Selection.Copy<o


ThisWorkbook.Activate<o


Sheets("NonProd Database").Activate<o


Range("A27").Select<o


IfRange("A27") = "" Or Range("A28") = ""Then<o


ActiveCell.Offset(0,1).Select<o


Else<o


Selection.End(xlDown).Select<o


ActiveCell.Offset(1, 1).Select<o


End If<o


Selection.PasteSpecial Paste:=xlValues<o


Application.CutCopyMode = False<o


Selection.Resize(Selection.Rows.Count + 1, 1).Offset(0, -1).Select<o


Selection.Value =Workbooks(fn).Name<o


Workbooks(fn).Activate<o


<o

