Thread: Ending a macro?
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Paul Paul is offline
external usenet poster
 
Posts: 661
Default Ending a macro?

I've got the following code working fine as a result of some wonderful
feedack from members., I just run the macro until it runs
out of data to find. The only problem is that when there is no more data to
find, the macro ends as an error. Is there any way of ending the macro
"cleanly"when there are no more entries?

Thanks again for the help.

Paul
Sub Pastedetails()

' Cutpaste Macro
' Macro recorded 22/11/2005 by IT Services
'
' Keyboard Shortcut: Ctrl+x

Sheets("Posting").Activate

x = Columns(3).Find("Reconciliations - Outstanding Items").Row
y = Columns(3).Find("Account Balance - Per master File").Row
z = Sheets("Posting").Cells(Rows.Count, "a").End(xlUp).Row + 1
Rows(x & ":" & y).Cut

Sheets("Summary").Activate
ActiveCell.SpecialCells (xlCellTypeLastCell)

ActiveSheet.Paste

Cells.Select
Cells.EntireColumn.AutoFit

Windows("Suspense1.xls").Activate
ActiveCell.SpecialCells(xlCellTypeLastCell).Offset (1, -5).Select

End Sub