ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with MACRO for opening workbook (https://www.excelbanter.com/excel-programming/447759-help-macro-opening-workbook.html)

sTUROB

Help with MACRO for opening workbook
 
Hi I want to open a workbook from a macro that has a date included in the name. I'd like it to open the newest one in the folder a new one is added every day.
Ive got this so far but what do change to make it open the latest date.

ChDir "P:\Conduit"
Workbooks.Open Filename:="P:\Conduit\Shift Checker - 29th November.xls", _
Notify:=False
Application.WindowState = xlMaximized
Range("F2:H4").Select
ActiveCell.FormulaR1C1 = "31770"
Range("F5").Select
Application.Run "'Shift Checker - 29th November.xls'!all"
End Sub

Thanks Stu

Max[_8_]

Help with MACRO for opening workbook
 
On Friday, November 30, 2012 10:28:52 PM UTC+11, sTUROB wrote:
Hi I want to open a workbook from a macro that has a date included in

the name. I'd like it to open the newest one in the folder a new one is

added every day.

Ive got this so far but what do change to make it open the latest date.



ChDir "P:\Conduit"

Workbooks.Open Filename:="P:\Conduit\Shift Checker - 29th

November.xls", _

Notify:=False

Application.WindowState = xlMaximized

Range("F2:H4").Select

ActiveCell.FormulaR1C1 = "31770"

Range("F5").Select

Application.Run "'Shift Checker - 29th November.xls'!all"

End Sub



Thanks Stu









--

sTUROB


This would open the file (provided the date was "today".

Sub tester()
Workbooks.Open Filename:="Shift Checker - " & Format(Date, "d") & "nd " & Format(Date, "mmmm") & ".xls"
End Sub


All times are GMT +1. The time now is 11:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com