VBA to open file using wildcard search WITH CONDITIONS

kgartin

Board Regular
Joined
May 6, 2010
Messages
207
Office Version
  1. 365
Platform
  1. Windows
SORRY! NEVERMIND! (I can't delete my post!)
 
Last edited:

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
If you already have code please show your code. I don't want to rewrite code you already have. I suggest pasting the code, selecting it, and clicking VBA to preserve your code formatting.
 
Upvote 0
If you are using Dir it will be something like this:
VBA Code:
Dim FName As String

FName = Dir(FL1-LD*PRESS REPORT*2024-09-05*) 
If InStr(UCase(Fname), "DIG") = 0 Then
   ' Open the file
End If
 
Upvote 0
If you are using Dir it will be something like this:
VBA Code:
Dim FName As String

FName = Dir(FL1-LD*PRESS REPORT*2024-09-05*)
If InStr(UCase(Fname), "DIG") = 0 Then
   ' Open the file
End If
Thanks so much man! I tried to delete my post because I figured it out, but I actually like your solution better!! Sweet!
 
Upvote 0
Now you've got me curious about what you did instead.

I made a critical error: That string in Dir has to be in quotes!!
VBA Code:
FName = Dir("FL1-LD*PRESS REPORT*2024-09-05*")
 
Upvote 0

Forum statistics

Threads
1,224,083
Messages
6,176,264
Members
452,718
Latest member
Nyxs_Inquisitor

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