opening a file that will have wildcards in VBA
NHWVBA
You can't use wildcards in Workbooks.Open or Workbooks.OpenText. What if more than one file has that format? Do you want to open all of them? Just the first one? You might look into the Dir function. You can use wildcards with Dir, but only * and ?, not #. To open the first file that looks like your string Dim aname as String Dim bname as String dim mypath as String aname = range("A1").Value & "??????.dat" mypath = "c:\documents" & Format(Int(Now()), "yyyy") & "\lists" & Format(Int(Now()), "mm-yyyy") & "\" bname = Dir(mypath & aname) If Len(baname) = 0 Then 'no file found Else Workbooks.OpenText mypath & bname End If -- Dick Kusleika MVP - Excel Excel Blog - Daily Dose of Excel www.dicks-blog.com |
All times are GMT +1. The time now is 11:16 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com