(Solved) – Disable Double-click Event for a Range When Criteria Met

(solved)-–-disable-double-click-event-for-a-range-when-criteria-met

I have the following macro that works great. It enters current date upon double-click:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Not Intersect(Target, Range("F5:Q42")) Is Nothing Then
        Cancel = True
        Target.Formula = Date
    End If                                                                                            
End Sub

But what I want to do is disable the click event for rows in the range when the COUNT of cells with date inputs reaches certain limits. For example, F5:Q5, I want to disable the click event (or cells otherwise unable to be actuated or date stamped) when four cells have values in them, so the macro cannot enter the date in a fifth cell. F6:Q6 would see the macro disabled when 12 cells receive dates, F7:Q7 would allow only 1 cell to be date stamped, and so on. Sort of like setting data validation limits on the double-click event.

Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *