Macro Open Workbook with Wilcard Character

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,570
Office Version
  1. 2021
Platform
  1. Windows
I have several workbooks in C:\my documents called for eg "BR1 Fixed assets 985600.xls"

I have tried to set up a macro to open these files using a wildcard character i.e *, but I get a message "sorry we coul'nt find C:\mydocuments\*985600.xls.....
Code:
 Sub OpenFiles()
  Workbooks.Open Filename:= _
         "C:\My Documents\*985600.xls", UpdateLinks:=3
   End Sub


It would be appreciated if someone could amend my code
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
I would think that code would confuse Excel.

For example, suppose you have:
A985600.xls
&
B985600.xls

Which one should it choose?
 
Upvote 0
As you have discovered, not at the same time with that same line of code. :rolleyes:
 
Last edited:
Upvote 0
Solution

Forum statistics

Threads
1,215,851
Messages
6,127,302
Members
449,374
Latest member
analystvar

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