Mrjcharlton

New Member
Joined
Aug 3, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello!

I am trying to use the below macro to flag an error message when a date range exceeds 7 days.

I have used the below which only applies to the first cell in the column. What must I do to apply it to the whole column, I have 350 rows.

Just to let you know column K is a calculation of days based on dates added to columns H & I.

Also, cell K492 has the value "7" in it.

Private Sub Worksheet_Change(ByVal Target As Range)

If Range("K2").Value > Range("K492").Value Then
MsgBox "Payroll Period can not be more than 7 days"
End If

End Sub





Thank you
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Welcome to the forum,

Do you really want to have multiple msgbox or would could you work with either a message in another cell or conditional formatting which would simply be easier.
 
Upvote 0
Thank you Trevor!

Ideally I just want something to pop up and alert the end user when they are doing something wrong. I.e adding a date range that exceeds 7 days

I have already added conditional formatting to flag as red if greater than 7. However, this has gone unnoticed in the past, which is very annoying.

Any suggestions would be greatly appreciated

Thanks
 
Upvote 0
Would a userform with a listbox showing either the rows that must be checked or something else as an identifier?
 
Upvote 0
Given the amount of data the end user needs to add, I think that would add a lot of extra work
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,725
Members
448,987
Latest member
marion_davis

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