do...if...loop problem

C

Carl

Hi, I've got a bit of code that loops until it finds a null cell. Within the
loop is a condition that checks for certain values, i.e.

count=1

do
if isempty(.........cells(3,count)) then exit do
if left(....cells(3,count),3)="see" then <-perform activity
end if
count=count+1
loop

When I execute thie code, it doesn't find a match, but when I walk through
the code using F8 it does.
Can anyone shed any light on this because it's driving me to distraction!

Many thanks
 
J

James Franklin

Hi, I've got a bit of code that loops until it finds a null cell. Within
the loop is a condition that checks for certain values, i.e.

count=1

do
if isempty(.........cells(3,count)) then exit do if
left(....cells(3,count),3)="see" then <-perform activity end if
count=count+1
loop

When I execute thie code, it doesn't find a match, but when I walk through
the code using F8 it does.
Can anyone shed any light on this because it's driving me to distraction!

Many thanks

Seems to me it would have found it on both occasions. When using F8, you
stopped whereas the program found other things to do then to simply stop
when it found your cell.

Is it possible you have nested loops or your code hangs elsewhere?

As a coding practice, this does not seem to be the place for an infinite
loop. You would be better served with an until clause "do until
isempty(...cells(2,count)) ... loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top