Prevent date being changed or deleted (VBA)

Craig__

Board Regular
Joined
Feb 16, 2010
Messages
66
Please would a VBA enthusiast help me out with this one. Your help is much appreciated.

On a worksheet, I need to allow user to enter a date into any cell in column H but not allow the date to be deleted or changed.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
I managed to put together this bit of code which stops the date from being deleted. But the problem is, it still allows the date to be changed:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)<o:p></o:p>
<o:p></o:p>
On Error GoTo ResetEvents<o:p></o:p>
Application.EnableEvents = False<o:p></o:p>
<o:p></o:p>
If Not Application.Intersect(Target, Range("H:H")) Is Nothing Then<o:p></o:p>
If IsDate(Target.Value) = True Then<o:p></o:p>
<o:p></o:p>
Application.EnableEvents = True<o:p></o:p>
Exit Sub<o:p></o:p>
Else<o:p></o:p>
Application.Undo
<o:p></o:p>
End If 'IsDate<o:p></o:p>
End If 'Not Application.Intersect
ResetEvents:<o:p></o:p>
Application.EnableEvents = True
<o:p></o:p>
End Sub<o:p></o:p>
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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