ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Not looping through rows (https://www.excelbanter.com/excel-programming/369388-not-looping-through-rows.html)

bg18461[_18_]

Not looping through rows
 

I have this function that makes 2 logical tests before it deletes that
value in that cell...

It searchs through a particular column in all rows that contain data
for any value that is not numeric and that is also not of length 3 and
deletes it.

My problem is that it does not seem to be looping, it goes until it
finds the next instance of my condition and then deletes but it does
not look again unless I run the macro again, any ideas.


--
bg18461
------------------------------------------------------------------------
bg18461's Profile: http://www.excelforum.com/member.php...fo&userid=8877
View this thread: http://www.excelforum.com/showthread...hreadid=568312


moon[_5_]

Not looping through rows
 
Give us the code.


"bg18461" schreef in
bericht ...

I have this function that makes 2 logical tests before it deletes that
value in that cell...

It searchs through a particular column in all rows that contain data
for any value that is not numeric and that is also not of length 3 and
deletes it.

My problem is that it does not seem to be looping, it goes until it
finds the next instance of my condition and then deletes but it does
not look again unless I run the macro again, any ideas.


--
bg18461
------------------------------------------------------------------------
bg18461's Profile:
http://www.excelforum.com/member.php...fo&userid=8877
View this thread: http://www.excelforum.com/showthread...hreadid=568312




Dave Peterson

Not looping through rows
 
Maybe it's the way you're looping through the rows.

I've found it much simpler to start at the bottom and work up when deleting
rows.

dim iRow as long
dim FirstRow as long
dim LastRow as long

with activesheet
firstrow = 2
lastrow = .cells(.rows.count,"A").end(xlup).row

for irow = lastrow to firstrow step -1
'do your checks and deletions
next irow
end with

bg18461 wrote:

I have this function that makes 2 logical tests before it deletes that
value in that cell...

It searchs through a particular column in all rows that contain data
for any value that is not numeric and that is also not of length 3 and
deletes it.

My problem is that it does not seem to be looping, it goes until it
finds the next instance of my condition and then deletes but it does
not look again unless I run the macro again, any ideas.

--
bg18461
------------------------------------------------------------------------
bg18461's Profile: http://www.excelforum.com/member.php...fo&userid=8877
View this thread: http://www.excelforum.com/showthread...hreadid=568312


--

Dave Peterson


All times are GMT +1. The time now is 03:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com