Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm trying to do a comparison operator that is being printed on an export
text file. What I am trying to do is this. See below: 1) If columns N and M in the worksheet have data, then I want them both stored into a string variable and then it is to be exported onto a text file. 2) If column N has data and column M is null, then only N is to be stored into a text string variable and then it is to be exported onto a text file. 3) If column M has data and column N is null, then only column M is to be stored into a text string variable and then it is to be exported onto a text file. 4) If columns N and M are null, then nothing is to be stored into the text string and the line will be skipped on the text file that is to be exported from Excel. 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. If IsEmpty(Cells(I, "N").Value) Or Cells(I, "N").Value = "" Then NVariable = "" Else: NVariable = Cells(I, "N").Value End If If IsEmpty(Cells(I, "M").Value) Or Cells(I, "M").Value = "" Then MVariable = "" Else: MVariable = Cells(I, "M").Value End If NandMVariable = NVariable + MVariable If IsEmpty(NandMVariable) Or NandMVariable = "" Then NANDMVARSTRING = "" ElseIf (NVariable = "" And MVariable < "") Then NANDMVARSTRING = "$DATUM " & MVariable & vbCrLf ElseIf (MVariable = "" And NVariable < "") Then NANDMVARSTRING = "$DATUM " & NVariable & vbCrLf ElseIf NandMVariable < "" Then NANDMVARSTRING = "$DATUM " & NVariable & "_" & MVariable & vbCrLf End If |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
IF Statement not working | Excel Worksheet Functions | |||
HELP: Comparison IF statement | Excel Worksheet Functions | |||
Date Comparison and IF statement | Excel Worksheet Functions | |||
If statement not working | Excel Programming | |||
Comparison Operators for IF statement. | Excel Worksheet Functions |