application.filesearch fix needed

mlmcelligott

New Member
Joined
Jun 20, 2014
Messages
2
Hi
Newbie here posting for the first time, hi everyone. Ive been given an old spreadsheet to use and there's an issue with application.filesearch and excel 2010. The code is below. Could one of you nice guys recommend a fix for it??

Code:
    Set blah = Application.FileSearch
    With Application.FileSearch
        .NewSearch
        .Filename = "*VaR*"
        .LookIn = directory
        .LastModified = msoLastModifiedAnyTime
        .Execute msoSortByLastModified, msoSortOrderDescending
    End With
    If blah.FoundFiles.Count = 0 Then
    MsgBox "Has a report been generated?"
    Exit Function
    Else
    End If
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
More detail

Code:
Dim blah As FileSearch
    Dim directory As String
    Dim i As Integer, iNewest As Integer
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Worksheets("Risk Vertex Allocation")
    Dim LastMod As Object
   
    Sheets("VaR Works Export").Select
    MsgBox "Clearing Previous Portfolio Information"
  
     Sheets("VaR Works Export").Range("a4:h65536").ClearContents
     Sheets("VaR Works Export").Range("i5:w65536").ClearContents
    
    directory = "[URL="file://\\headfop006v\VarWorks"]\\headfop006v\VarWorks[/URL]"
    Set blah = Application.FileSearch
    With Application.FileSearch
        .NewSearch
        .Filename = "*VaR*"
        .LookIn = directory
        .LastModified = msoLastModifiedAnyTime
        .Execute msoSortByLastModified, msoSortOrderDescending
    End With
    If blah.FoundFiles.Count = 0 Then
    MsgBox "Has a VaR export report been generated?"
    Exit Sub
    Else
    End If
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,559
Members
449,089
Latest member
Motoracer88

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