Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Open file based on yesterday's date


Hello,
Everyday when I come in I have to open the an excel file from th
previous day. For instance, today I had to open “workbook 8-30.xls
and tomorrow I’ll have to open “workbook 9-1.xls”. I was thinkin
there might be a way to have this open for me automatically when I ope
Excel. Any ideas on what the macro for this should look like?
Thanks

--
ForSal
-----------------------------------------------------------------------
ForSale's Profile: http://www.excelforum.com/member.php...fo&userid=1189
View this thread: http://www.excelforum.com/showthread.php?threadid=40133

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Open file based on yesterday's date

Add this to the ThisWorkbook module of your PERSONAL.xls file;

Private Sub Workbook_Open()
Dim flname As String
Dim path As String

path = "C:/Temp/"

On Error Resume Next
flname = Month(Date) & "-" & Day(Date) & ".xls"
Workbooks.Open (path & flname)
On Error GoTo 0

End Sub

Hope this helps
Rowan

"ForSale" wrote:


Hello,
Everyday when I come in I have to open the an excel file from the
previous day. For instance, today I had to open €œworkbook 8-30.xls€
and tomorrow Ill have to open €œworkbook 9-1.xls€. I was thinking
there might be a way to have this open for me automatically when I open
Excel. Any ideas on what the macro for this should look like?
Thanks.


--
ForSale
------------------------------------------------------------------------
ForSale's Profile: http://www.excelforum.com/member.php...o&userid=11896
View this thread: http://www.excelforum.com/showthread...hreadid=401337


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Open file based on yesterday's date

I think that the OP wanted yesterday's date. So this line:

flname = Month(Date) & "-" & Day(Date) & ".xls"
could be:
flname = Month(Date-1) & "-" & Day(Date-1) & ".xls"
or just:
flname = format(date-1,"m-d") & ".xls"

Rowan wrote:

Add this to the ThisWorkbook module of your PERSONAL.xls file;

Private Sub Workbook_Open()
Dim flname As String
Dim path As String

path = "C:/Temp/"

On Error Resume Next
flname = Month(Date) & "-" & Day(Date) & ".xls"
Workbooks.Open (path & flname)
On Error GoTo 0

End Sub

Hope this helps
Rowan

"ForSale" wrote:


Hello,
Everyday when I come in I have to open the an excel file from the
previous day. For instance, today I had to open €œworkbook 8-30.xls€
and tomorrow Ill have to open €œworkbook 9-1.xls€. I was thinking
there might be a way to have this open for me automatically when I open
Excel. Any ideas on what the macro for this should look like?
Thanks.


--
ForSale
------------------------------------------------------------------------
ForSale's Profile: http://www.excelforum.com/member.php...o&userid=11896
View this thread: http://www.excelforum.com/showthread...hreadid=401337



--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Display yesterday's date but only for weekdays? totalnatal Excel Worksheet Functions 8 November 15th 12 04:43 PM
Date open file with date saved Rita Excel Worksheet Functions 3 April 23rd 09 03:13 PM
Can I restore yesterday's file? Stress Excel Discussion (Misc queries) 4 December 27th 07 06:29 PM
Open file and print sheets based on data in cell Steph[_6_] Excel Programming 3 August 23rd 05 08:47 PM
VBA to call file based on date fLiPMoD£ Excel Discussion (Misc queries) 2 April 23rd 05 09:24 PM


All times are GMT +1. The time now is 09:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright İ2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"