UserForm closes after Selection.Insert (RESOLVED)

  • Thread starter Thread starter DFS
  • Start date Start date
D

DFS

Excel 2003

I have a form with a button that inserts one row. As soon as the Insert
executes, the form closes and the code quits.

i = ActiveCell.Row
Rows(i + 1).Select
Selection.Insert

I also tried: Rows(i + 1).Insert
on the last line, and no dice.


Resolution: close the sheet and reopen and it works.

Lesson learned: Excel sometimes works in mysterious ways.
 
The only way the form iwll close if there is code that does this or there is
an Error. I recommend doing two things

1) In VBA menu change the option
tools - Option - General - Error trapping - Break on All Errors

2) Comment out all 'On Error" statements until you get the code working.
The error trapping could be shtting down the userform.


You now should be able to find the problem and fix the problem.
 
change this

i = ActiveCell.Row
Rows(i + 1).Select
Selection.Insert

TO
i = ActiveCell.Row
activesheet.rows(i).Insert
 
Back
Top