UserForm closes after Selection.Insert (RESOLVED)

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.
 
J

Joel

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.
 
P

Patrick Molloy

change this

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

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top