Cell Drag Drop

Blobajob88

Board Regular
Joined
Mar 27, 2020
Messages
55
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi, I want to ensure a date is entered in a cell

If Not IsDate(Target.Value) Then

Application.EnableEvents = False
Target.Value = ""
MsgBox "Please Enter A Valid Date", vbCritical, "Invalid Data Type"
Application.EnableEvents = True

Target.Select
Application.EnableEvents = True
Sheet1.Protect
Exit Sub
End if

This works fine but if I drag the cell value down that has a date in it, this code runs. How can I avoid this?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
You can use The Intersect Method, i.e.
VBA Code:
If Not Intersect(Target, Range("D4")) Is Nothing Then 'your validated range
    If Not IsDate(Target.Value) Then
        {YOUR CODE}
    Else
        Exit Sub
    End If
End If
 
Upvote 0
Hi, I tried this but when I'm dragging it down, it is not seeing a date even I'm dragging down dates and so it is running the code I have and giving the message box to enter a valid date
 
Upvote 0
Hello!
What do you imply when you say "dragging down dates"? Could you post a sample data (with XL2BB) of worksheet? What's the sheet name?
 
Upvote 0
Hi, I am still new here. I can't figure out how to post a new question. But, I have locked sheets with some unlocked cells. The unlocked cells are referred to by another locked cell with a formula. How can I stop my employees from dragging open cells to avoid getting an invalid reference? please help.
 
Upvote 0

Forum statistics

Threads
1,214,415
Messages
6,119,381
Members
448,888
Latest member
Arle8907

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