Having a message box pop of if a date in one cell is greater than a date in another cell plus a number of days

Scottyp123

New Member
Joined
Dec 16, 2020
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
I have a cell K1 that has a specific date, I want to set up a visual basic sub to pop up a message box if k1 is greater than m1 plus 7 days. I want this to pop up upon entry of the date in cell k1 as this field will change upon use of the spreadsheet. Not great with the visual basic section of excel and needing help.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
So you said:
entry of the date in cell k1 as this field will change upon use of the spreadsheet.

So you will not always be entering Date in K1?

And will M1 always change also?

Would you be saying your entry date will be put in any cell in column K
And the other date will be in any cell in column M

So you may enter a date in K14 and will want script to look for date in M14

Would this be what your wanting?

And the dates entered in Column K will be entered manually by user correct?
Not the result of a formula.
 
Upvote 0
Welcome to the Board!

Right-click on the sheet tab name at the bottom of your screen, select "View Code", and paste this VBA code in the resulting VB editor window:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.CountLarge > 1 Then Exit Sub
   
'   Run if cell K1 updated
    If Target.Address = Range("K1").Address Then
'       See if K1 is greater than M1 + 7
        If Target > (Range("M1") + 7) Then MsgBox "K1 is more than M1 + 7"
    End If
       
End Sub
This will run automatically upon them entering data in cell K1.
You can change the MsgBox text to say whatever you want.
 
Upvote 0
You are welcome.
Glad we could help!
:)
 
Upvote 0

Forum statistics

Threads
1,214,815
Messages
6,121,715
Members
449,049
Latest member
THMarana

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