exit sub after insert row

  • Thread starter Thread starter Xiaoping Yao
  • Start date Start date
X

Xiaoping Yao

Hi there:

Please help. The following code dosn't work. Similar code worked perfect
in other cases:

Private Sub MovetoClosedLoan()
Dim selr As Integer

'get selected row
selr = Selection.Row

'insert rows
Worksheets("ClosedLoan").Rows(11).Insert

'copy from loanpipeline to closed loan
Worksheets("LoanPipeLine").Rows(selr).Copy
Worksheets("ClosedLoan").Rows(11)

'delete from loanpipeline
Worksheets("LoanPipeLine").Rows(selr).Delete

'end of sub
End Sub

The execution will stop right after 'insert rows. The rest of the code will
not been executed and no error message.

Thanks.

Xiaoping
 
maybe if you step through your macro, you might find execution does not
actually stop. Instead, maybe your code

Worksheets("ClosedLoan").Rows(11)

is missing the paste method?
 
or rather pastespecial if applied to a range and paste if applied to the sheet
 
Checked my previous case involving the same code. Difference is my previous
worksheet doesn't have conditional formating and this one does. Took all
the conditional formating out and the code works perfect. But I do need the
conditional formatting. Seems to me whenever the conditinal formatting is
involved, any of insert and copy method will have trouble. How to get
around with this problem?

Xiaoping
 

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

Back
Top