Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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, 13:31
lijon lijon is offline
Registered User
 
Join Date: Mar 2008
Posts: 2
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, 13:26
stuschmied stuschmied is offline
Registered User
 
Join Date: May 2008
Location: Raleigh, NC
Posts: 138
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

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