Hi Guys,
I need help with my code for duplicating table rows. Currently, this is what i have
but i keep getting the error "The operation is not allowed. The operation is attempting to shift cells in a table in your worksheet."
Can you give me a sample code to duplicate the current selected row in a table?
thank you so much in advance
I need help with my code for duplicating table rows. Currently, this is what i have
Code:
Dim rng As Range
Dim shtControlAssignment As Worksheet
Set shtControlAssignment = ThisWorkbook.Worksheets(cstrControlAssignment)
Application.DisplayAlerts = False
Application.EnableEvents = False
Application.ScreenUpdating = False
On Error Resume Next
With Selection.Cells(1)
Set rng = Intersect(.EntireRow, ActiveCell.ListObject.DataBodyRange)
On Error GoTo 0
If rng Is Nothing Then
MsgBox "Please select table row.", vbCritical
Else
If MsgBox("Proceed to duplicate selected rows? Yes/No.", vbQuestion + vbSystemModal + vbYesNo, cProjName) = vbYes Then
'Set your range
Set rng = .Rows(ActiveCell.Row)
'Insert the range
rng.Offset(1).Insert Shift:=xlDown
'Copy and Paste the Selected range
Selection.Copy
ActiveCell.Offset(1).PasteSpecial
'Clear the clipboard.
Application.CutCopyMode = False
End If
End If
End With
Can you give me a sample code to duplicate the current selected row in a table?
thank you so much in advance