View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
HappySenior HappySenior is offline
external usenet poster
 
Posts: 15
Default Extracting portion of filename

On Jul 12, 9:26*am, "Gary Keramidas" <GKeramidasATmsn.com wrote:
this may or may not work depending on your filename. if it's exactly like you
show, this should work.

Sub test()
Dim fn As String
Dim dt As Variant
fn = "test 2008 07 12"
dt = Split(fn, " ")
Range("A2").Value = DateSerial(dt(1), dt(2), dt(3))
End Sub
--

Gary

"HappySenior" wrote in message

...



I have a macro that creates a series of workbooks named in the format
"Daily yyyy mm dd" which works fine.
My daily worksheets require a column headed by the date and another
column headed by the preceding day's date. That column links to the
prior day's worksheet to bring forward end of the day values.
I'm a newbie (retired CPA) at VBA and would appreciate suggestions
about how to extract the right 10 characters of the file name and
convert them to a date in cell c1 on sheet 1.
Many thanks
Don- Hide quoted text -


- Show quoted text -

Gary, your solution is fine except I needed a way to macro enter the
filename in your variable fn. See my note to Bob Phillips. I have
learned from both of you.