In my sheet I have 5 columns filled with data and when I double click on any cell it will show Input box to enter "Number of rows" and copies multiple times. Till here everything works fine but my requirement is to only copy two columns data (A & B) and clear the Contents of other column data only for the created new rows.
My Excel data:
Present Solution is:
My Requirement should look like below:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim xCount As Integer
LableNumber:
xCount = Application.InputBox("Number of Rows", "Copy previous data of Team and Place", , , , , , 1)
If xCount < 1 Then
MsgBox "the entered number of rows is error, please enter again", vbInformation
GoTo LableNumber
End If
ActiveCell.EntireRow.Copy
'copy and move down
Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(xCount, 0)).EntireRow.Insert Shift:=xlDown
'clear the contents only for new rows added from the column C to column D
Sheets(ActiveSheet.Name).Range(ActiveCell.Offset(1, 4), ActiveCell.Offset(1, 4)).Select
Selection.ClearContents
Application.CutCopyMode = False
End Sub