VBA version of Data validation

RobSully

New Member
Joined
Jul 16, 2012
Messages
14
I am currently using data validation a date column that checks entered dates fall within 90 days before or after the entry date. The problem is that on occasion rows get deleted and the workbooks get many hands in them and throw off the validation. How would you go about using VBA as a check on the date just entered. Currently I just use a warning as there are occasions to date outside this range I am just looking to slow down the entry and have person double check an odd date.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
You could use the Worksheet_Change event procedure, but if you are going to use VBA it may be more effective to restore the data validation when the workbook opens.
 
Upvote 0
you could create a simple change event function on the entry sheet.

Something like this:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)


If Target.Column = 4  and Target.Value <> "" Then
    If (Abs(Target.Value - Now()) > 90) Then
        Target.Interior.Color = 65535
    End If
End If
End Sub
 
Upvote 0
You could use the Worksheet_Change event procedure, but if you are going to use VBA it may be more effective to restore the data validation when the workbook opens.
Thank You that worked really well, I should of thought of that ... Yesterday may have been worse than I thought :)
 
Upvote 0

Forum statistics

Threads
1,203,430
Messages
6,055,331
Members
444,781
Latest member
rishivar

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