79821666

Date: 2025-11-16 18:32:53
Score: 0.5
Natty:
Report link
Option Explicit

Private oldAddress As String

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    On Error Resume Next

    ' Prevent drag fill by breaking the selection extension
    If oldAddress = Selection.Address Then
        Exit Sub
    End If
    
    oldAddress = Selection.Address
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo exitsafe
    If Application.EnableEvents = False Then Exit Sub
    Application.EnableEvents = False

    ' --- Detect autofill drag (Excel always delivers big block change)
    If Target.Cells.CountLarge > 1 And Application.CutCopyMode = False Then
        Application.Undo
        MsgBox "Drag Fill is disabled on this sheet.", vbExclamation
        GoTo exitsafe
    End If
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Ahmed Magdy Tpozada