Thread: If condition
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Rpettis31 Rpettis31 is offline
external usenet poster
 
Posts: 49
Default If condition

The only reason I was doing the one liner was this is in a loop and kept
giving me an error Next without for. I am assuming the _ takes care of that
issue.

"Rick Rothstein (MVP - VB)" wrote:

Personally, I think one-liner If-Then statements should be confined to when
the entire statement would be **short** (otherwise it will be hard to read
when you come back to your code six months from now to modify it) and your
code line does not qualify, so I would write it this way...

If Cells(Valid, 13) < "" And Cells(Valid, 19) < "" And _
(Cells(Valid, 19) - Cells(Valid, 13)) < 20 Then
Cells(Valid, 30) = Cells(Valid, 8) & CEDissue
End If

However, if you are insistent in listing it on one line, this what it would
look like (your newsreader will probably wrap the line because of it length,
so you will have to account for that)

If Cells(Valid, 13) < "" And Cells(Valid, 19) < "" And (Cells(Valid, 19) -
Cells(Valid, 13)) < 20 Then Cells(Valid, 30) = Cells(Valid, 8) & CEDissue

By the way, note that I changed your cell value tests of greater than "" to
not equal to "" which is what I assumed you were trying to check.

Rick


"Rpettis31" wrote in message
...
Is there a way to have this condition read in this one line.
IF cells(valid,13)"" and (cells(valid,19)""and
((cells(valid,19)-cells(valid,13))< 20 then
cells(valid,30)=cells(valid,8)&CEDissue

I am sure I am not following the correct syntax for the nested if but I am
having a hard time finding the correct syntax in this case.

Thanks