Disable Drag and drop for a particular range in Worksheet

H_gupta

New Member
Joined
Mar 26, 2019
Messages
31
I have a worksheet A , in which I want to disable dragging functionality for a particular range of cells. for eg: D24 to D100
All other columns and cells in the sheet should be allowed to drag.

Found this code, but its for the complete workbook :

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

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

H_gupta

New Member
Joined
Mar 26, 2019
Messages
31
Thanks, i used the following code as given in the links

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim myRange As Range
Set myRange = Worksheets("Sheet1").Range("A5:E10")
'In above statement set your range for which you want no drag drop
If Application.Intersect(Target, myRange) Is Nothing Then
Application.CellDragAndDrop = True
Else
Application.CellDragAndDrop = False
End If
End Sub


But it isnt working !
 

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
8,203
Office Version
  1. 2016
Platform
  1. Windows
Thanks, i used the following code as given in the links

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim myRange As Range
Set myRange = Worksheets("Sheet1").Range("A5:E10")
'In above statement set your range for which you want no drag drop
If Application.Intersect(Target, myRange) Is Nothing Then
Application.CellDragAndDrop = True
Else
Application.CellDragAndDrop = False
End If
End Sub


But it isnt working !
Are you putting the code in the corresponding correct sheet module ?
Also, are you changing the target range address in the above code from "A5:E10" to "D24:D100" ?
 

H_gupta

New Member
Joined
Mar 26, 2019
Messages
31
Are you putting the code in the corresponding correct sheet module ?
Also, are you changing the target range address in the above code from "A5:E10" to "D24:D100" ?
Yes put the correct sheet name and range. What it did once was disabled the drag option for the entire sheet instead of just the range. And then the option was disabled for all other excel sheets as well.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,439
Messages
5,636,296
Members
416,911
Latest member
jafornwalt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top