#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default VBA For Expiry date

Dear All
please any one can help me.
If My Data Like
NAME PASSPORT NO. ISSUED DATE PASSPORT EXPIRY DATE
LOUIS HENNERY B125556 5/5/2004 5/5/2007
VICTOR H. S A125586 1/9/2005 1/9/2008

I want when I open this data file, MsgBox showing the list name of staff
their passport is near or already expired.
Thanks


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default VBA For Expiry date

Private Sub Workbook_Open()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long
Dim iLastRow As Long

With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To iLastRow 'iLastRow to 1 Step -1
If .Cells(i, "D").Value Date - 7 Then
MsgBox .Cells(i, TEST_COLUMN).Value & _
" will/has expired on " & _
.Cells(i, "D").Text
End If
Next i

End With
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Alam" wrote in message
...
Dear All
please any one can help me.
If My Data Like
NAME PASSPORT NO. ISSUED DATE PASSPORT EXPIRY DATE
LOUIS HENNERY B125556 5/5/2004 5/5/2007
VICTOR H. S A125586 1/9/2005 1/9/2008

I want when I open this data file, MsgBox showing the list name of staff
their passport is near or already expired.
Thanks




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
How to calculate expiry date Justina New Users to Excel 6 August 19th 11 07:20 PM
Expiry date Martina Excel Worksheet Functions 6 February 11th 07 09:57 PM
Date Expiry function Aleks Excel Discussion (Misc queries) 6 December 18th 06 07:59 PM
Date of expiry - warning? Jonas Excel Worksheet Functions 5 January 27th 06 08:21 PM
how do i set up an expiry date in an Excel worksheet AR Voice Excel Worksheet Functions 2 June 6th 05 10:22 PM


All times are GMT +1. The time now is 09:59 AM.

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

About Us

"It's about Microsoft Excel"