Private Sub CommandButton1_Click()
Dim ANS As String
Dim x As String
ActiveSheet.Unprotect password:="password"
ANS = MsgBox("Do you want to insert new rows here?", vbYesNo, "Insert Rows")
Select Case ANS
Case vbYes
x = InputBox("How many Rows do you want to insert?", "Number of Rows to Insert", "1")
Select Case x
Case vbOK
Range(ActiveCell, ActiveCell.Offset(x - 1, 0)).EntireRow.Insert
ActiveSheet.Protect password:="password"
Case Else
ActiveSheet.Protect password:="password"
Exit Sub
End Select
Case vbNo
ActiveSheet.Protect password:="password"
Exit Sub
End Select
End Sub
Try this. I reduced the unnecessary code, hope you don't mind.
Private Sub CommandButton1_Click()
Dim ANS As String, x As String
ANS = MsgBox("Do you want to insert new rows here?", vbYesNo, "Insert Rows")
If ANS = vbNo Then Exit Sub
x = InputBox("How many Rows do you want to insert?", "Number of Rows to Insert", "1")
If x = "" Then Exit Sub
Dim z As Long
z = ActiveCell.Row
ActiveSheet.Unprotect Password:="password"
ActiveCell.Resize(x).EntireRow.Insert
Range(Cells(z, 10), Cells(z + x - 1, 12)).MergeCells = True
Range(Cells(z, 13), Cells(z + x - 1, 15)).MergeCells = True
ActiveSheet.Protect Password:="password"
End Sub