How to Create Notifications using VBA in Microsoft Excel 2010

In this article, you will learn how to create notification or alert wherein the code will check each cell in Due Date column & automatically update the user if the due date has been passed or 7 days from expiration.

There is couple of ways to create notification in Excel i.e. Conditional Formatting & VBA

In this example, we will use VBA code.

 

Let us take an example:

We have bills in column A & due date in column B.
 
img1
 
Click on Developer tab & click on Visual Basic to launch VB Editor Screen.

You can also use ALT + F11 shortcut key.
 
img2
 
Enter the following code in This Workbook
 
img3
 
Private Sub Workbook_Open()

    For Each cell In Range("B2:B8")

        If cell.Value< Date + 7 Andcell.Value<> "" Then

cell.Interior.ColorIndex = 6

cell.Font.Bold = True

        End If

    Next

End Sub
 
img4
 
The above code will get activated; check the dates in column every time this workbook gets open & highlight the cells in Yellow color & bold font.
 
img5
 
You can increase or decrease the range of column B according to your requirement.

In this way, you can highlight the due dates cells which are expired & 7 days left for passing the due date.

With above example, you can create various notifications or alert depending on the requirement.
 
 

Leave a Reply

Your email address will not be published. Required fields are marked *

Terms and Conditions of use

The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.