ddavis5891
New Member
- Joined
- Apr 5, 2023
- Messages
- 5
- Office Version
- 365
- 2010
- Platform
- Windows
Hi everyone,
Moving with the times, haha I'm testing several macro excel files in Windows 10 which have been working in Windows 7. I've got some VBA code in one of my files which does not work in Windows 10. I was hoping for some assistance as to what i can replace Application.FileSearch? Very much appreciate any help here! My code is as follows -
Moving with the times, haha I'm testing several macro excel files in Windows 10 which have been working in Windows 7. I've got some VBA code in one of my files which does not work in Windows 10. I was hoping for some assistance as to what i can replace Application.FileSearch? Very much appreciate any help here! My code is as follows -
VBA Code:
Range("nrgCC_Start").Select
x = 0
Do Until ActiveCell.Offset(x, 0).Value = ""
strCost_Centre = ActiveCell.Offset(x, 0).Value
If strDivision <> ActiveCell.Offset(x - 1, 1).Value Then
strReport_Date = Format(Range("nrgReport_Date").Value, "mmm-yy")
strDivision = ActiveCell.Offset(x, 1).Value
Workbooks.Open "c:\Cost Analysis\Cost Centre Template v1.4 - ND.xls", False, True, , "jkl"
End If
On Error GoTo 0
Set wbCodeBook = ThisWorkbook
With Application.FileSearch
.NewSearch
.LookIn = "c:\Cost Analysis\" & strReport_Date
.FileType = msoFileTypeExcelWorkbooks
.Filename = "Payroll Cost Analysis " & strCost_Centre & " " & strReport_Date & ".xls"
If .Execute > 0 Then
For lCount = 1 To .FoundFiles.Count
Set wbResults = Workbooks.Open(Filename:=.FoundFiles(lCount), UpdateLinks:=0)
ThisWorkbook.Activate
ActiveCell.Offset(x, 2).Value = "Copied"
Workbooks("Payroll Cost Analysis " & strCost_Centre & " " & strReport_Date & ".xls").Activate
Worksheets("Employee Breakdown").Select
If Range("A4").Value <> "" Then
Range("nrgEmp_Whole").Copy
lngCCRowCount = Range("nrgEmp_Whole").Rows.Count
Workbooks("Cost Centre Template v1.4 - ND.xls").Activate
Worksheets("Employee Breakdown").Select
Range("A4").Select
Do Until ActiveCell.Value = ""
ActiveCell.Offset(1, 0).Select
Loop
lngCCRowStart = ActiveCell.Row
ActiveCell.PasteSpecial xlPasteAll
lngCCLimit = lngCCRowStart + (lngCCRowCount - 1)
For lngCCCurrentRow = lngCCRowStart To lngCCLimit
Worksheets("Employee Breakdown").Cells(lngCCCurrentRow, 7).Value = strCost_Centre
Next lngCCCurrentRow
End If