A
Alan
Hi All,
Using Excel 2000 SP3 (all patches installed to date - 19 Nov 2003).
I would like to be able to disable the drag / copy functionality that
exists in Excel by default.
I may have used the wrong terminology, so for the avoidance of doubt,
this is what I mean:
1) Open a worksheet
2) Type in anything to A1
3) Select Al
4) Using the mouse, drag A1 across one or two columns using the little
black square that is in the bottom right hand corner when A1 is
selected.
5) This copies A1 across, or creates a series from A1 across (doesn't
matter which for my query).
*Background*
Basically, I am trying to have some control over a worksheet (data
sheet). I can disable copy / paste fine (since it is often a filtered
table and copy / paste is quite dangerous in that situation), and I
have used validation via VBA (WorksheetChange event) to stop users
entering, for example, past dates into certain cells.
However, they can still get a past date into those cells by dragging
across as outlined above which does not seem to trigger the
WorksheetChange event, or otherwise circumvents that code (see below
for the code I am using).
I need to either:
A) Disable that drag / copy; OR
B) Stop the effect in some other way.
Just ask if you need more details.
Thanks in advance,
Alan.
****************************************
*Code in use to catch past dates*
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrHandler:
If Intersect(Target, Range("S4:S9999")) Is Nothing Then GoTo
ErrHandler
Application.EnableEvents = False
NewValue = Target.Value
If ((OldValue < NewValue) * (OldValue > 1)) Then
Target.Value = OldValue
Response = MsgBox("You cannot change the work in date to a
more recent date.", vbOKOnly, "Warning")
End If
ErrHandler:
Application.EnableEvents = True
End Sub
Using Excel 2000 SP3 (all patches installed to date - 19 Nov 2003).
I would like to be able to disable the drag / copy functionality that
exists in Excel by default.
I may have used the wrong terminology, so for the avoidance of doubt,
this is what I mean:
1) Open a worksheet
2) Type in anything to A1
3) Select Al
4) Using the mouse, drag A1 across one or two columns using the little
black square that is in the bottom right hand corner when A1 is
selected.
5) This copies A1 across, or creates a series from A1 across (doesn't
matter which for my query).
*Background*
Basically, I am trying to have some control over a worksheet (data
sheet). I can disable copy / paste fine (since it is often a filtered
table and copy / paste is quite dangerous in that situation), and I
have used validation via VBA (WorksheetChange event) to stop users
entering, for example, past dates into certain cells.
However, they can still get a past date into those cells by dragging
across as outlined above which does not seem to trigger the
WorksheetChange event, or otherwise circumvents that code (see below
for the code I am using).
I need to either:
A) Disable that drag / copy; OR
B) Stop the effect in some other way.
Just ask if you need more details.
Thanks in advance,
Alan.
****************************************
*Code in use to catch past dates*
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrHandler:
If Intersect(Target, Range("S4:S9999")) Is Nothing Then GoTo
ErrHandler
Application.EnableEvents = False
NewValue = Target.Value
If ((OldValue < NewValue) * (OldValue > 1)) Then
Target.Value = OldValue
Response = MsgBox("You cannot change the work in date to a
more recent date.", vbOKOnly, "Warning")
End If
ErrHandler:
Application.EnableEvents = True
End Sub