There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Business Applications
Tag Cloud
access acer asus bios bsod computer crash drive driver drivers error ethernet excel freeze games gaming graphics hard drive hardware hdmi internet laptop malware memory monitor motherboard netgear network printer problem ram random registry router slow software sound trojan usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless xbox
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Business Applications >
Solved: Disable the cut function in excel to prevent users from messing up formulas !

Reply  
Thread Tools
titanalive's Avatar
Senior Member with 102 posts.
 
Join Date: May 2007
Experience: Picking Up Steadly
09-Feb-2010, 08:05 AM #1
Solved: Disable the cut function in excel to prevent users from messing up formulas !
Hi,

I had to create an excel file for my workplace which is to be accessed by many users and this excel file relies on formulas for quite a bit of calculations that need to be done internally.

Now the problem with excel is that if a user cuts pastes data in any referenced cell, the formula referenceing to that cell tends to throw a #REF error, so thus to prevent users from causing this error I pasted the following code in the ThisWorkbook module of VBA :

Option Explicit
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Excel.Range)

Select Case Application.CutCopyMode
Case Is = False
'do nothing
Case Is = xlCopy
'do nothing
Case Is = xlCut
MsgBox "Please DO NOT Cut and Paste. Use Copy and Paste; then delete the source."
Application.CutCopyMode = False 'clear clipboard and cancel cut
End Select

End Sub

Private Sub Workbook_Activate()
Application.CellDragAndDrop = False
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CellDragAndDrop = True
End Sub

Private Sub Workbook_Deactivate()
Application.CellDragAndDrop = True
End Sub

Private Sub Workbook_Open()
Application.CellDragAndDrop = False
End Sub

Now while the above code achieved the intended goal it created another problem in the form that sometimes when users have to copy data into the workbook from another workbook, the data does not get copied as the paste option remains disabled. (PS. The copy and paste works for the workbook internally).

I dont know what I am doing wrong or what is missing in the above code, but any help in this would be great.

Thanks
__________________
Titans were not a joke
Keebellah's Avatar
Computer Specs
Senior Member with 3,539 posts.
 
Join Date: Mar 2008
Location: Oegstgeest, The Netherlands
Experience: Never too old to learn!
09-Feb-2010, 08:22 AM #2
Take a look at this site (link)

http://www.vbaexpress.com/kb/getarticle.php?kb_id=373

It has serveral examples.

Happy coding
titanalive's Avatar
Senior Member with 102 posts.
 
Join Date: May 2007
Experience: Picking Up Steadly
10-Feb-2010, 07:47 AM #3
Thanks for the above link Keebelah. It really helped me crack another code I was stuck with.

Anyway as far as the code above was concerned (code in my earlier post) the solution to that too turned out to be simple.

The reason why copy was gettin disabled was due to the cell drag property being disabled.
Just using the first half of the code i.e.

Option Explicit
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Excel.Range)

Select Case Application.CutCopyMode
Case Is = False
'do nothing
Case Is = xlCopy
'do nothing
Case Is = xlCut
MsgBox "Please DO NOT Cut and Paste. Use Copy and Paste; then delete the source."
Application.CutCopyMode = False 'clear clipboard and cancel cut
End Select

End Sub

Fulfills the need to block any cut fuction used in the workbook.
__________________
Titans were not a joke
Keebellah's Avatar
Computer Specs
Senior Member with 3,539 posts.
 
Join Date: Mar 2008
Location: Oegstgeest, The Netherlands
Experience: Never too old to learn!
10-Feb-2010, 12:56 PM #4
Happy to help
waki's Avatar
Junior Member with 4 posts.
 
Join Date: Mar 2010
Experience: Intermediate
01-Mar-2010, 07:55 PM #5
thanks guys, it does work..
but how do you restore it to normal?
thanks..
Keebellah's Avatar
Computer Specs
Senior Member with 3,539 posts.
 
Join Date: Mar 2008
Location: Oegstgeest, The Netherlands
Experience: Never too old to learn!
02-Mar-2010, 01:56 AM #6
reverse the codes.
You hav a macro diabling, wel copy the macro, rename it i.e. Back2Normal and set the values you set to false to true and v.v.
waki's Avatar
Junior Member with 4 posts.
 
Join Date: Mar 2010
Experience: Intermediate
02-Mar-2010, 10:15 AM #7
thanks man, i will try that, btw, do you know how to digitally sign the above macro?coz every time I open this workbook, Excel warns me about my own macro and offers to Enable/ Disable macro execution. How can I get around this nuisance?
Keebellah's Avatar
Computer Specs
Senior Member with 3,539 posts.
 
Join Date: Mar 2008
Location: Oegstgeest, The Netherlands
Experience: Never too old to learn!
02-Mar-2010, 03:43 PM #8
If you're not on a public network and it's your own PC you may set your macro security level to low.
If you're working with Office 2007 you add secure locations, which would be a harddrive drive folder of your choice and all the excel sheets from that folder will be considered secure.
I use a vbs script for my files that overrides any security setting
__________________
Cheers,
Hans
It's all in the code... and may the code be with you! If it isn't . . . start debugging! (Time zone: Western Europe)
waki's Avatar
Junior Member with 4 posts.
 
Join Date: Mar 2010
Experience: Intermediate
02-Mar-2010, 06:48 PM #9
i found a solution moments ago, is a seld-signed certficate safe enough? the solution here is pretty simple http://office.microsoft.com/en-us/he...7811033.aspx#1
thanks..
waki's Avatar
Junior Member with 4 posts.
 
Join Date: Mar 2010
Experience: Intermediate
02-Mar-2010, 06:51 PM #10
i have another problem.. it seems like its not possible to highlight, or change font Color on a cell that is unlocked but from a protected sheet.. do you guys know of any solution?
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 03:27 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.