Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default Prevent copy and paste in one column

I am having trouble trying to prevent copying and pasting in one specific
column. The code refers to the specific range, but yet it prevents copying
and pasting on the whole worksheet.

Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Columns("H:H")) Is Nothing Then
Application.CellDragAndDrop = False
Application.CutCopyMode = False
Else
Application.CellDragAndDrop = True
End If

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Prevent copy and paste in one column

Works for me in Excel 2003


Gord Dibben MS Excel MVP

On Fri, 30 Apr 2010 11:42:01 -0700, Brian
wrote:

I am having trouble trying to prevent copying and pasting in one specific
column. The code refers to the specific range, but yet it prevents copying
and pasting on the whole worksheet.

Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Columns("H:H")) Is Nothing Then
Application.CellDragAndDrop = False
Application.CutCopyMode = False
Else
Application.CellDragAndDrop = True
End If

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default Prevent copy and paste in one column


I was thinking it would for me too.... but in 2007 it is not working. Well
correction, it is working too well, it prevents every column not just H....
any ideas?

"Gord Dibben" wrote:

Works for me in Excel 2003


Gord Dibben MS Excel MVP

On Fri, 30 Apr 2010 11:42:01 -0700, Brian
wrote:

I am having trouble trying to prevent copying and pasting in one specific
column. The code refers to the specific range, but yet it prevents copying
and pasting on the whole worksheet.

Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Columns("H:H")) Is Nothing Then
Application.CellDragAndDrop = False
Application.CutCopyMode = False
Else
Application.CellDragAndDrop = True
End If

End Sub


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Prevent copy and paste in one column

Misread your original.

Thought you just wanted to prevent drag and drop in H

Try this simple revision to prevent pasting into H or drag and drop in H

Will not prevent copying from H

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column < 8 Then Exit Sub
Application.CellDragAndDrop = False
Application.CutCopyMode = False
End Sub


Gord

On Mon, 3 May 2010 13:46:01 -0700, Brian
wrote:


I was thinking it would for me too.... but in 2007 it is not working. Well
correction, it is working too well, it prevents every column not just H....
any ideas?

"Gord Dibben" wrote:

Works for me in Excel 2003


Gord Dibben MS Excel MVP

On Fri, 30 Apr 2010 11:42:01 -0700, Brian
wrote:

I am having trouble trying to prevent copying and pasting in one specific
column. The code refers to the specific range, but yet it prevents copying
and pasting on the whole worksheet.

Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Columns("H:H")) Is Nothing Then
Application.CellDragAndDrop = False
Application.CutCopyMode = False
Else
Application.CellDragAndDrop = True
End If

End Sub


.


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
Can you prevent Copy-Paste from changing formatting without macros DCramlet Excel Discussion (Misc queries) 6 May 30th 14 07:18 AM
Prevent Copy/Paste Q Seanie Excel Programming 9 October 22nd 08 09:56 PM
Unable to prevent copy/paste of protected worksheet into new docum Richard R. Excel Programming 11 May 2nd 07 04:27 AM
How to prevent copy/paste of cell with validation? Joe HM Excel Programming 0 May 11th 06 10:14 PM
prevent the copy and paste function sir Lancelot Excel Discussion (Misc queries) 1 December 8th 05 01:16 AM


All times are GMT +1. The time now is 09:36 PM.

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

About Us

"It's about Microsoft Excel"