If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Variable File Selection?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-04-08, 12:31
lijon lijon is offline
Registered User
 
Join Date: Mar 2008
Posts: 8
Variable File Selection?

Hi Folks,
I wrote the following macro the old-fashioned way (I recorded it!). It looks up and opens a file in another directory.
but here's the thing: the file name will change! Is there a way I can modify the code to just get the MOST RECENT wk3 file? or ignore parts of the file name?

Optimally, it would ignore the "391640" part, maybe just look for something with today's date?

Appreciate any input!!!
L


Sub Macro2()
'
' Macro2 Macro
' Macro recorded 6/4/2008 by L
'
Workbooks.Open Filename:= _
"W:\mtm_trade.391640_1.7595_SW.04-Jun-08.WAILER_.WAILER_.wk3"

Range("B5").Select
blah blah blah
blah blah blah

End Sub
Reply With Quote
  #2 (permalink)  
Old 06-06-08, 12:26
stuschmied stuschmied is offline
Registered User
 
Join Date: May 2008
Location: Raleigh, NC
Posts: 151
Hey,

Using code you could look into your directory for a file with a particular name or filter. Then set a variable with that name and use the macro to call code that opens the file with that variable name.

Hope this helps.
__________________
--If its free, take it for what its worth!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On