Disable Drag and drop for a particular range in Worksheet

H_gupta

New Member
Joined
Mar 26, 2019
Messages
33
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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
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 !
 
Upvote 0
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" ?
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

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
Back
Top