MsgBox before date in specified cell

inta251

New Member
Joined
Nov 27, 2010
Messages
31
Worksheet 'REFUND_FORM', cell B10 formated as date.
Need VB scrip MsgBox. If in cell B10 date, let say 11/28/2010 message box will start popup as reminder 10 days before date in cell B10, when each time i will click on REFUND_FORM tab.

Sample:
B10 = 11/28/2010
MsgBox will start popup from 11/18/2010.
"10 days left before send your Refund Form for refund".

Thanks in advance.
inta251. Igor.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Select Worksheet "REFUND_FORM" then press ALT+F11 copy and paste the following code in blank pane on Right side.

Code:
Private Sub Worksheet_Activate()
On Error Resume Next
Dim d As Date
d = Range("B10").Value
    If d <= Date And d >= Date - 10 Then
        MsgBox ("10 days left before send your Refund Form for refund")
    End If
End Sub
 
Last edited:
Upvote 0
Right-click on the REFUND_FORM tab and select View Code
Paste the code below in the VBA edit window

Code:
Private Sub Worksheet_Activate()

    Dim DaysRemaining As Long
    
    DaysRemaining = Range("B10") - Date
    
    Select Case DaysRemaining
        Case Is < 0: MsgBox "Past due for refund.", vbInformation, "Refund Reminder"
        Case Is = 0: MsgBox "Last day to send your Refund Form for refund.", vbInformation, "Refund Reminder"
        Case Is <= 10: MsgBox DaysRemaining & " days left before send your Refund Form for refund.", vbInformation, "Refund Reminder"
    End Select
    
End Sub
 
Last edited:
Upvote 0
Thanks guys for reply!
Cloverken, for some reason your script not working.
AlphaFrog, your script perfect, but only problem, when cell B10 empty message still showup "Past due for refund."
You guys PRO!

Private Sub Worksheet_Activate()
Dim DaysRemaining As Long

DaysRemaining = Range("B10") - Date

Select Case DaysRemaining
Case Is < 0: MsgBox "Past due for Refund.", vbInformation, "Refund Reminder"
Case Is = 0: MsgBox "Last day to send your Refund Request for refund.", vbInformation, "Refund Reminder"
Case Is <= 10: MsgBox DaysRemaining & " days left before send your Refund Request for refund.", vbInformation, "Refund Reminder"
End Select

End Sub
 
Upvote 0
Code:
Private Sub Worksheet_Activate()

    Dim DaysRemaining As Long
    
    [COLOR="Red"]If IsDate(Range("B10")) Then
[/COLOR]    
        DaysRemaining = Range("B10") - Date
        
        Select Case DaysRemaining
            Case Is < 0: MsgBox "Past due for refund.", vbInformation, "Refund Reminder"
            Case Is = 0: MsgBox "Last day to send your Refund Form for refund.", vbInformation, "Refund Reminder"
            Case Is = 1: MsgBox "One day left to send your Refund Form for refund.", vbInformation, "Refund Reminder"
            Case Is <= 10: MsgBox DaysRemaining & " days left to send your Refund Form for refund.", vbInformation, "Refund Reminder"
        End Select
        
    [COLOR="Red"]End If[/COLOR]
    
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,102
Messages
6,170,122
Members
452,303
Latest member
c4cstore

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