Chewyhairball
Active Member
- Joined
- Nov 30, 2017
- Messages
- 312
- Office Version
- 365
- Platform
- Windows
Hi
This bit of code lets me move rows around in a table using an input box to select the destination.
It works fine except when i click 'cancel' in which case is give a runtime 424 object required error.
any ideas how to fix this?
thanks
Rory
This bit of code lets me move rows around in a table using an input box to select the destination.
It works fine except when i click 'cancel' in which case is give a runtime 424 object required error.
any ideas how to fix this?
thanks
Rory
VBA Code:
Sub Move_Selected_Cells()
Dim fromrange As Range
Dim torange As Range
Set fromrange = Range(ActiveCell.Offset(0, -2), ActiveCell.Offset(0, 22))
Set torange = Application.InputBox(Title:="Select Destination", prompt:="Select where you want to item/s to be moved to then click OK", Type:=8)
ActiveSheet.Unprotect
On Error Resume Next
Application.ScreenUpdating = False
If torange Is Nothing Then GoTo errorhandler
On Error GoTo enableeventson:
Application.EnableEvents = False
Range(torange.Offset(0, -2), torange.Offset(0, 22)).Value = fromrange.Value
fromrange.ClearContents
Application.EnableEvents = True
On Error GoTo 0
Application.ScreenUpdating = True
enableeventson:
Application.EnableEvents = True
ActiveSheet.Protect
errorhandler:
ActiveSheet.Protect
End Sub