Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This workbook contains three columns - column C is an occasional "X"
inserted by another macro. A macro is supposed to run down Col C and delete any row containing "X". It works fine, skipping past blank rows and deleting X'ed rows - until it processes Row 8, that is. I just stepped through this *again* looking at variable values after each step. NowRow was 7, LastRow was 76, C was blank. The macro Offset one row as programmed, updated NowRow to 8, went to Loop, AND THEN WENT TO END SUB! Fourth time in a row! Can someone drop-kick me in the direction of "WHY?!?" Ed _______________________ Sub BBoxUpdate() Dim NowRow As String Dim LastRow As String ' Find end of used range LastRow = Range("A65536").End(xlUp).Row ' Start at C1 and search down Range("C1").Select NowRow = ActiveCell.Row Do While NowRow <= LastRow ' If cell has "X", delete row If ActiveCell.Value < "" Then ActiveCell.EntireRow.Delete ' and update LastRow LastRow = Range("A65536").End(xlUp).Row Else ' Drop one row ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Select NowRow = ActiveCell.Row ' update variable End If Loop End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VLOOKUP - calculating multiple hits | Excel Discussion (Misc queries) | |||
When countdown hits zero | Excel Discussion (Misc queries) | |||
MS Excel 2003 CTRL+F missing hits | Excel Discussion (Misc queries) | |||
multiple hits in random sequences | Excel Worksheet Functions | |||
lookup help with multiple hits | Excel Worksheet Functions |