View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Brett Smith[_2_] Brett Smith[_2_] is offline
external usenet poster
 
Posts: 54
Default I'm trying to do a comparison if statement but it is not worki

Thank you very much JE McGimpsey, you were very helpful!

"JE McGimpsey" wrote:

First, since you make an assignment to NandMVariable, it should never be
empty, so

IsEmpty(NandMVariable)

should always return false.

Second, since you're using the + operator, but not getting a Type
mismatch error, I assume your data in N and M is text. If that's the
case, I'd recommend using the & operator.

The only way I got your results was to have numeric data in one cell,
the other cell blank (or text) and have an On Error Resume Next
statement operative. Since that ignores the type mismatch error, no
assignment will be made to NandMVariable so the first IsEmpty() will
return true, and NANDMVARSTRING will be the null string.

However, it appears to me that your routine could be substituted by
something like

NandMString = ""
With Cells(I, "M").Resize(1, 2)
If Len(.Item(1).Text) + Len(.Item(2).Text) Then
NandMString = "$DATUM " & .Item(1).Text & _
IIf(Len(.Item(1).Text) And Len(.Item(2).Text), "_", "") & _
.Item(2).Text & vbCrLf
End If
End With


In article ,
"Brett Smith" wrote:


Everything works fine and the text file displays both of the fields properly
when they both have data, but if one of the columns is blank, then nothing
shows up on the text file. Why is this happening? Below is my logic for the
code, please see below.