User entry check on dates

Timmo7410

New Member
Joined
Nov 30, 2013
Messages
13
Hi Guys,

Have the following block of code below.

I have a line in red that I want to use to check that the end date is not earlier than the start date. If so, display the MsgBox advising that they can't enter data that way.

This currently isn't working very well (Ok, at all), any thoughts would be greatly appreciated.

-------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Not Application.Intersect(Target, Range("D16:D100", "E16:E100")) Is Nothing Then
Call DateCheck
End If
If IsEmpty(Cells(Target.Row, "D")) = False And IsEmpty(Cells(Target.Row, "E")) = False Then
If Cells(Target.Row, "E") > Cells(Target.Row, "D") Then
Cells(Target.Row, "F") = (Cells(Target.Row, "E") - Cells(Target.Row, "D")) + 1
End If
Else: MsgBox "Sorry, End Date can't be before Start Date"
End If
End Sub
--------------------------------------

Cheers.
 

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.
Also, this code only seems to perform the mathatical difference in dates (i.e. Target.Row, "F") = (Cells(Target.Row, "E") - Cells(Target.Row, "D")) + 1) once.

Is there any way to Loop this ?

I tried putting a loop in but crashed the macro and had to break out of it.

Thanks again,
Tim.
 
Upvote 0

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

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