Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can a named range be protected???

For example, If I had a worksheet used to collect 10
financial values, with the 10 cells named FinVal1 thru
FinVal10 respectively, locked all other cells on the
sheet, protected the sheet...

Now, as an example if a user Cuts the cell named FinVal1
and pastes it over the cell that is named FinVal6, then
FinVal6 will no longer exist.

Is here a way to prevent users from pasting cell obects
over others that are named? This silently creates havoc
elsewhere in the spreadsheet that may reference the
former named range.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 473
Default Can a named range be protected???

John D wrote:
Is here a way to prevent users from pasting cell obects
over others that are named? This silently creates havoc
elsewhere in the spreadsheet that may reference the
former named range.


You would need to disable the ability to Cut (or replace Paste with
Paste Special / Values)

Something like this:

In a normal module:

Sub MyPaste()
If ActiveWorkbook.Name = ThisWorkbook.Name Then
ActiveCell.PasteSpecial xlValues
Else
ActiveSheet.Paste
End If
End Sub

Sub GrabCutAndPaste()
Dim CB As CommandBar
Dim CTL As CommandBarControl
For Each CB In Application.CommandBars
Set CTL = CB.FindControl(ID:=22, recursive:=True)
If Not CTL Is Nothing Then
CTL.OnAction = "MyPaste"
End If
' disable cut
Set CTL = CB.FindControl(ID:=21, recursive:=True)
If Not CTL Is Nothing Then
CTL.Enabled = False
End If

Next
Application.OnKey "^x", ""
Application.OnKey "+{DELETE}", ""
Application.OnKey "^v", "MyPaste"
Application.OnKey "+{INSERT}", "MyPaste"
Application.CellDragAndDrop = False
Application.CutCopyMode = False
End Sub

Sub ReleaseCutAndPaste()
Dim CB As CommandBar
Dim CTL As CommandBarControl
For Each CB In Application.CommandBars
Set CTL = CB.FindControl(ID:=22, recursive:=True)
If Not CTL Is Nothing Then
CTL.OnAction = ""
End If
' enable cut
Set CTL = CB.FindControl(ID:=21, recursive:=True)
If Not CTL Is Nothing Then
CTL.Enabled = True
End If
Next
Application.OnKey "^x"
Application.OnKey "+{DELETE}"
Application.OnKey "^v"
Application.OnKey "+{INSERT}"
Application.CellDragAndDrop = True
End Sub

' and in ThisWorkbook

Private Sub Workbook_Activate()
GrabCutAndPaste
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ReleaseCutAndPaste
End Sub

Private Sub Workbook_Open()
GrabCutAndPaste
End Sub


Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
List Box - For Input Range can I use named range in another workbo dim Excel Worksheet Functions 2 January 3rd 08 06:10 PM
Referencing a named range based upon Range name entry in cell Barb Reinhardt Excel Worksheet Functions 14 June 20th 07 07:19 PM
automatic range - named range give me circular reference... George Thorogood Excel Discussion (Misc queries) 0 February 22nd 07 07:53 PM
Array as a "named range" - formula ok in cells, but error as "named range" tskogstrom Excel Discussion (Misc queries) 11 December 28th 06 04:44 PM
inserting a named range into new cells based on a named cell Peter S. Excel Discussion (Misc queries) 1 June 4th 06 03:53 AM


All times are GMT +1. The time now is 11:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"