LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
PE PE is offline
external usenet poster
 
Posts: 14
Default Macro problem

I am trying to write a macro which would:
1) check the cell to the left - if value is 0 (or cell is empty) then macro
is abandoned else......
2) if current cell is non-empty then the row is deleted and back to 1) to
check the next row
3) if current cell is empty then move down 1 cell and back to 1)

I have tried the following:
Sub DeleteRow_If_Cell_NotEmpty()
Do
If ActiveCell.Offset(0, -1).Value 0 Then
If ActiveCell < "" Then
Selection.EntireRow.Delete
Else 'go to next row
ActiveCell.Offset(1, 0).Select
End If
Else
Exit Sub
End If

Loop
End Sub

If I step into the macro using F8 in VB editor it works fine. But when I
use the macro normally I get the error "Code execution has been interrupted"
and on clicking the debug button the first End If above is highlighted.

Would appreciate your help.

Al


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
Color Row Macro Problem, adapted from Patrick Malloy macro SteveC Excel Programming 4 June 21st 06 12:28 PM
Problem in updating all worksheets of a workbook using a macro that calls another macro [email protected] Excel Programming 3 March 20th 06 05:21 AM
Macro Problem Brad Excel Programming 2 January 4th 05 04:41 PM


All times are GMT +1. The time now is 02:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"