• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

vba macro to find file with its name starting with specified text

Nidhi07

New Member
Hi All,

I am trying to find an excel with file name starting with specific text in a folder and if it is found then execute some series of commands. Below is the code I've attempted.

>>> use code - tags <<<
Code:
Set fso = CreateObject("Scripting.filesystemobject")
     sSFolder = Worksheets("Sheet 1").Range("A1").Value
     sFile = "*SKU360*"
If Not fso.fileexists(sSFolder & "\" & sFile) Then
    Sheets("Industry").Select

Else
       
    Workbooks.Open Filename:=sSFolder & "/" & sFile
A1 range in sheet 1 has the path of the folder where the file needs to be searched. "SKU360" is the text with which the file name starts. The above code doesn't go to the else commands even though there is an excel with filename starting with "SKU360". What am I doing wrong.
 
Last edited by a moderator:
Back
Top