views:

38

answers:

1

When writing an Excel formula, does it make a difference whether you set a value to true, "true", or true()?

In other words, which of the following is the best? Or does it depend on the circumstances?

if (A1 = 1, true, false)

if (A1 = 1, "true", "false")

if (A1 = 1, true(), false())
+3  A: 

I would strongly suggest avoiding the second method, as you're using a string literal. If you us the second method in a cell, then need to refer to the second cell's value later, you won't be able to use TRUE or TRUE() to compare it against.

As far as I'm aware, first or third method really doesn't make much of a difference. TRUE() is simply an Excel function that returns TRUE.

LittleBobbyTables
That makes sense, thanks! Was wondering because another programmer used true and "true" interchangeably in Excel, so I will correct that. BTW I read your profile - I'm a .NET programmer in VBA exile, so I feel your pain.
LCountee
Glad to be of help! Isn't exile grand?
LittleBobbyTables
A grind, yes. Grand, not so much. :P
LCountee