Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stop Cell Dragging 2

Status
Not open for further replies.

simoncpage

Programmer
Apr 4, 2002
256
GB
hi all,

Does anyone know of a way of stopping someone from dragging a cell down on a sheet? I want to preserve a range naming order but not limit the page so that it is protected?

Anny help appreciated!

Thanks

Simon
 
Hi,

When you say Draging, you do mean MOVE?

Only ways I know are sheet protection OR using an IS/WAS technique which employs a phantom very hidden sheet that has the WAS sheet state. So if a Move occurs in a specified range, then you retore the WAS condition.

BTW, this uses the Worksheet_Change event. But you must prevent recursive calls to the restore procedure.

Hope this helps :)

Skip,
Skip@TheOfficeExperts.com
 
sorry, hit the wrong button...

You can disable event processing to prevent recursive calls by using...
Code:
Application.EnableEvents = False
RestoreWAS
Application.EnableEvents = True
:)

Skip,
Skip@TheOfficeExperts.com
 
or.....
Tools>Options>Edit
untick allow cell drag and drop

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
heh heh - one of those things I accidently unticked for a while and had to hunt for it to turn it back on....that's the only reason I know about it.

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
WOW it does go to show theres me looking into some snazzy whorksheet change code and all I need to do is that lol

Cheers for the help Skip! I always go by the thought process that Excel isn't as functional as I can make and I think in most cases that helps!

Simon
 
Although this has thrown up another problem as I only want the stop cell drag to be present when using a specific model rather than all excel sheets open,

So just having:

Private Sub Workbook_WindowActivate(ByVal Wn As Window)
Application.CellDragAndDrop = False
End Sub

in the workbook activate and opposite for the Deactivate event should work yes? But it doesn't seem to? any ideas?

 
simon,

Your approch works on worksheet_Activate/Dactivate...
Code:
Private Sub Worksheet_Activate()
    Application.CellDragAndDrop = False
End Sub

Private Sub Worksheet_Deactivate()
    Application.CellDragAndDrop = True
End Sub
Try get away from WINDOW referencing and into Workbook/Worksheet/Range refreencing.

:)

Skip,
Skip@TheOfficeExperts.com
 
simon,

Your approch works on worksheet_Activate/Dactivate...
Code:
Private Sub Worksheet_Activate()
    Application.CellDragAndDrop = False
End Sub

Private Sub Worksheet_Deactivate()
    Application.CellDragAndDrop = True
End Sub
Try get away from WINDOW referencing and into Workbook/Worksheet/Range refreencing.

BTW -- use the WORKSHEET OBJECT and NOT a module when coding this!

:)

Skip,
Skip@TheOfficeExperts.com
 
Yeah I of course have it as a worksheet object sub - I dont see why taking the "ByVal Wn As Window" out would make any differnce anyhow? WHich it doesn't still not working. Its probably my cell stop drag coding I had in thats not making it work as that code on another blank book is fine.

thx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top