PDA

View Full Version : Display alert when target date is less than current date



rajagopal
10-30-2008, 01:28 AM
Hi,
I've an excel file which has a column - Target date. I want a alert display message to be shown when the user opens the document, the condition being target date is less than the current date.

I've calendar user form which will be shown when the user place the cursor in the cell range H7:J3173. I want the ESC key to be enabled i.e. when the user clicks Esc key, the calendar has to disappear.

I attach the file for your ref.

bye
Raj

Bob Phillips
10-30-2008, 02:26 AM
Just set the Cancel property of the Cancel button to True.

rajagopal
10-30-2008, 05:27 AM
That is fine.
What about my other requirement - I've an excel file which has a column - Target date. I want a alert display message to be shown when the user opens the document, the condition being target date is less than the current date.

Raj

Bob Phillips
10-30-2008, 05:59 AM
Exactly, you have a column, what if there are many less than?

rajagopal
10-30-2008, 06:38 AM
Irrespective of the nos. a single alert message will do.

rajagopal
10-30-2008, 10:56 AM
Can anyone help with my requirement?

Bob Phillips
10-30-2008, 11:47 AM
Private Sub Workbook_Open()
Dim i As Long

With Worksheets("Action item tracker")

For i = 2 To .Cells(.Rows.Count, "I").End(xlUp).Row

If .Cells(i, "I").Value < Date Then

MsgBox "Dates less than today"
Exit For
End If
Next i
End With
End Sub

rajagopal
10-30-2008, 10:46 PM
Can you give explain me the codes:
For i = 2 To .Cells(.Rows.Count, "I").End(xlUp).Row

If .Cells(i, "I").Value < Date Then

rajagopal
10-30-2008, 10:49 PM
The alert message should not be displayed when there is no items in the Target date column(Column H)..

Alert message has to be displayed when the date given in the column H is less than today date.

Bob Phillips
10-31-2008, 03:18 AM
Can you give explain me the codes:
For i = 2 To .Cells(.Rows.Count, "I").End(xlUp).Row

If .Cells(i, "I").Value < Date Then

The first line calculates the last row of data and runs a loop from row 2 to that last line.

The second just compares the value of the current cell in the loop against today's date.

rajagopal
10-31-2008, 03:26 AM
I want this alert to be triggered only when any of the action item having target date is less than today's date.
Right now, the code displays the alert message even in the blank tempalte.

Can you also look into the post
http://vbaexpress.com/forum/showthread.php?t=23232

Bob Phillips
10-31-2008, 03:31 AM
Private Sub Workbook_Open()
Dim i As Long

With Worksheets("Action item tracker")

For i = 6 To .Cells(.Rows.Count, "I").End(xlUp).Row

If .Cells(i, "I").Value < Date Then

MsgBox "Dates less than today"
Exit For
End If
Next i
End With
End Sub