Logic for a FOR loop
Hi Bob,
Im really really sorry for not mentioning this in my initial post.
I tried the code on my own and it did work.
But being new to this I wanted to be very very sure ( as the format will be
a standard one which will be used by others to give data to me)
that what I wanted to do and what I have translated in to VBA is the same or
not. I was thinking I may have overlooked some scenario in this, like I
wasnt fully confident about having a Exit for statement within a If
statement.
(Im now thankful that I did ask u folks because Frank suggested one
improvement in my code to speed up which I had overlooked.)
Thanx again,
Regards,
Hari
India
On the
"Bob Phillips" wrote in message
...
Hari,
Surely, if it compiles okay, then you test it, and see if the results are
as
expected. You won't learn by asking us to validate your code before you
have
even tried to see whether there is a problem or not.
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Hari" wrote in message
...
Hi,
I want to exit a FOR loop if a particular cell's value meets one of the
target values and would not want to wait till all conditions are
checked.
No.of possible target /desired values are 19 and if the cells' value is
not
equal to any of those 19 then color the cell with a yellow color and
increase the count for Nooferrors by one.
I just wanted to ask whether the LOGIC in the following loop is correct.
(
My syntax seems to be fine as Im able to compile the project without any
problem)
Please advise.
For m = 0 To 18
definedtype = False
temp = UCase(Sheets(sheetName).Cells(n, 3))
If reasons(m) = temp Then
definedtype = True
Exit For
End If
Next m
If definedtype = False Then
Sheets(sheetName).Cells(n, 3).Interior.ColorIndex = 6
NoOfErrors = NoOfErrors + 1
End If
Regards,
Hari
India
|