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

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
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,221,517
Messages
6,160,260
Members
451,635
Latest member
nithchun

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