Expiring date with message box

woobinhyul

New Member
Joined
Jan 26, 2023
Messages
5
Office Version
  1. 365
  2. 2010
  3. 2007
  4. 2003 or older
Platform
  1. Windows
Good Morning to all!
I am new to excel VBA and my excel in office is 2010 version, may I ask a help to you guys about VBA.
Can someone teach me how to do a message box with all my expiring date, items that it will expire in a month before the expire date, and the message box will show until the day before it expires.
Hoping someone care to help. Thank you from Philippines.
 
In this example there is a Date value in cell A1 on Sheet1. A message will appear if that date is less than 30 days away. You should be able to build on that.
VBA Code:
Sub chkDate()
Dim wb As Workbook, sht As Worksheet, rng As Range, cell As Range, d
Set wb = ThisWorkbook: Set sht = wb.Sheets(1)
Set rng = sht.Cells(1, 1)  'you can also use Set rng = sht.Range("A1")
Debug.Print Day(Now()) - Day(rng.Value)
d = Day(Now()) - rng.Value
If d < 30 Then
    MsgBox "Date is less than 30 days away.", vbInformation, "Expiration"
End If
End Sub
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,214,950
Messages
6,122,438
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top