How to allow for "don't care" when getting a file

Grue42

New Member
Joined
Feb 11, 2011
Messages
10
Hello!
Maybe this is easy, but I don't know how to search for it.
I have some code tha
t goes looking for a specific filename in a specific format based on some user input.

example: 555_Part_01.01.11_Test.csv


The user would enter "555", "Part", and "Test" - but does not know the date. Excel needs to go open that file.


I currently use:


file_Name = Cells(3, 3).Value + "_" + Cells(4, 3).Value + "_" + ******** + "_" + Cells(5,3) + ".csv"


to make up the file name. Where the asterisks are I need a "don't care" - does Excel VBA has this? (Also, does it have a technical name? I'm sort of an impromptu coder, but I'm trying to learn!)

Thank you!
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Maybe like this:

Code:
    Dim sFilt As String
    Dim sFile As String
 
    sFilt = LCase([c3] & "_" & [c4] & "_*_" & [c5] & ".csv")
    sFile = LCase("555_Part_01.01.11_Test.csv")
 
    If sFile Like sFilt Then
        MsgBox "We have a winner!"
    End If

See Help for the Like operator.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,082
Messages
6,128,713
Members
449,464
Latest member
againofsoul

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