Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Business Applications Business Applications
Search Search
Search for:
Tech Support Guy > > >

Solved: Disable the cut function in excel to prevent users from messing up formulas !


(!)

titanalive's Avatar
titanalive titanalive is offline
Senior Member with 102 posts.
THREAD STARTER
 
Join Date: May 2007
Experience: Picking Up Steadly
09-Feb-2010, 07: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
Keebellah's Avatar
Keebellah   (Hans) Keebellah is offline Keebellah is a Trusted Advisor with special permissions. Keebellah has a Profile Picture
Computer Specs
Trusted Advisor with 5,463 posts.
 
Join Date: Mar 2008
Location: Oegstgeest, The Netherlands
Experience: Advanced
09-Feb-2010, 07: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
titanalive titanalive is offline
Senior Member with 102 posts.
THREAD STARTER
 
Join Date: May 2007
Experience: Picking Up Steadly
10-Feb-2010, 06: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.
Keebellah's Avatar
Keebellah   (Hans) Keebellah is offline Keebellah is a Trusted Advisor with special permissions. Keebellah has a Profile Picture
Computer Specs
Trusted Advisor with 5,463 posts.
 
Join Date: Mar 2008
Location: Oegstgeest, The Netherlands
Experience: Advanced
10-Feb-2010, 11:56 AM #4
Happy to help
waki's Avatar
waki waki is offline
Junior Member with 4 posts.
 
Join Date: Mar 2010
Experience: Intermediate
01-Mar-2010, 06:55 PM #5
thanks guys, it does work..
but how do you restore it to normal?
thanks..
Keebellah's Avatar
Keebellah   (Hans) Keebellah is offline Keebellah is a Trusted Advisor with special permissions. Keebellah has a Profile Picture
Computer Specs
Trusted Advisor with 5,463 posts.
 
Join Date: Mar 2008
Location: Oegstgeest, The Netherlands
Experience: Advanced
02-Mar-2010, 12: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
waki waki is offline
Junior Member with 4 posts.
 
Join Date: Mar 2010
Experience: Intermediate
02-Mar-2010, 09: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
Keebellah   (Hans) Keebellah is offline Keebellah is a Trusted Advisor with special permissions. Keebellah has a Profile Picture
Computer Specs
Trusted Advisor with 5,463 posts.
 
Join Date: Mar 2008
Location: Oegstgeest, The Netherlands
Experience: Advanced
02-Mar-2010, 02: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
waki's Avatar
waki waki is offline
Junior Member with 4 posts.
 
Join Date: Mar 2010
Experience: Intermediate
02-Mar-2010, 05: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
waki waki is offline
Junior Member with 4 posts.
 
Join Date: Mar 2010
Experience: Intermediate
02-Mar-2010, 05: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?
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
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)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑

Content Relevant URLs by vBSEO 3.3.2