lewadan
02-02-2007, 05:34 AM
Is it possible to have a workbook open automatically if today's date matches a date that is located in a range from A10 through A30 in the workbook?
Thanks
Bob Phillips
02-02-2007, 06:41 AM
If Not IsError(Application.Match(CLng(Date), Worksheets("Sheet1").Range("A10:A30"), 0)) Then
Workbooks.Open ("C:\myFile.xls")
End If
mdmackillop
02-02-2007, 02:56 PM
Hi Lewadan,
Welcome to VBAX
As I understand the question, paste the following into the ThisWorkbook module of Personal.xls
Option Explicit
Private Sub Workbook_Open()
ProcessFiles
End Sub
Sub ProcessFiles()
Dim MyPath As String, MyName As String
Dim Sheet As String, Address As String
Dim d As Long
MyPath = "C:\AAA\"
MyName = "TestDate.xls"
For d = 10 To 30
If GetData(MyPath, MyName, "Sheet1", "A" & d) = Date Then
Workbooks.Open (MyPath & MyName)
Exit For
End If
Next
End Sub
Private Function GetData(Path, File, Sheet, Address)
Dim Data As String
Data = "'" & Path & "[" & File & "]" & Sheet & "'!" & _
Range(Address).Range("A1").Address(, , xlR1C1)
GetData = ExecuteExcel4Macro(Data)
End Function
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.