LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default can't find error in macro logic...

I have a piece of mcro code that is giving me grief, but I cannot fin
the error in the logic:

The purpose is to loop through the second column until there is no mor
data in the column, searching for nulls. If there is a null in a cel
from that column, the row needs to be deleted. But it will not detec
consecutive null cells, so it is only deleting every second row that
want it to.

'Find the end of the range, to set the bounds of th
function:

Dim areaCount As Integer

Columns(1).Select
ActiveCell.CurrentRegion.Select
areaCount = Selection.Rows.Count
Dim counter As Integer

'Loop through from (1, 2) to (end, 2) deleting rows with null in th
cells.

For counter = 1 To areaCount
If Cells(counter, 2).Value = 0 Then
Rows(counter).Delete
End If
Next counter

So it should be going:

Is (1, 2) null? Nope. Next cell.
Is (2,2) null? Nope, Next cell
Is (3, 2) null? Yep, Delete the row. Next Cell...

If anyone can tell me where I am going wrong here, or just paste
working algorithm I would be very grateful.

.tehw

--
Message posted from http://www.ExcelForum.com

 
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
Excel 2007-macro programming logic for data validation Derek Megyesi Excel Discussion (Misc queries) 2 February 1st 10 01:34 AM
Find Macro Error StillLearning Excel Discussion (Misc queries) 5 December 11th 09 06:58 PM
Is there is a 90% chance of a logic error per 150 lines per workbo Jay Excel Discussion (Misc queries) 3 April 9th 09 06:03 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
macro error "can't find project or library" Meinfs Excel Programming 3 September 14th 03 04:29 PM


All times are GMT +1. The time now is 07:08 AM.

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

About Us

"It's about Microsoft Excel"