Simple "If" formula is not working.

raven_squire

Board Regular
Joined
Jan 13, 2013
Messages
99
Hello,

I have a table that is populated by a macro from a log file. I have a column in the table that compares the value in a column and returns true or false =IF([@[Truck number]] = "unknown",TRUE,FALSE). Problem is that this is always returning false.

I have tried similar (simple IF) formulars on different columns and some work and others don't. All the values in columns come from the same txt file and the number type of the cells is always "General". Data in the columns is generally text or text and numbers. I have evaluated the formulars and it seams that "Apples" does not = "Apples"

What am I missing?
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
See if this works

=IF(TRIM([@[Truck number]]) = "unknown",TRUE,FALSE)

If it doesn't work, the data contain extraneous characters and you need to clean up them.

M.
 
Upvote 0
I was already triming the data in the cells. But you are right there is an extra char in the cell. It is 13 or Carriage return I believe. This is the code I am using to import the log file, how do I strip out the carriage returns?

'****Open the log file****
Open LogFilePath For Input As #1
strLogFileContent = Input$(LOF(1), #1 )
Close #1

'Split the file blob into lines seperating at the VBLF
LogLines = Split(strLogFileContent, vbLf)
Set strLogFileContent = Nothing
 
Upvote 0
I think I worked it out. I added this code after the code above.

'clean out the Carriage Return charecters
For LogRow = 0 To UBound(LogLines)
If Right(LogLines(LogRow), 1) = Chr(13) Then
LogLines(LogRow) = Left(LogLines(LogRow), Len(LogLines(LogRow)) - 1)
End If
Next LogRow
 
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,017
Members
448,937
Latest member
BeerMan23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top