ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Compare two cells from reference cells (https://www.excelbanter.com/excel-worksheet-functions/57371-compare-two-cells-reference-cells.html)

Mike K

Compare two cells from reference cells
 
Oh wise ones,
I have two cells that I am comparing. The values come from an array
function that is pulled from a sql server, so the reference cells are not
very editable. Lets call them A1 and A2. I refer to them in B1 and B2 where I
compare them for equality. They look identical, but they do not compare as
true so there must be some leading/trailing spaces. How can I take out the
spaces from B1 and B2 so they compare properly?

Thanks,
Mike

bpeltzer

Compare two cells from reference cells
 
TRIM will removing leading and trailing spaces. Another common cause of
failure to match is a difference between a number (123) and a string
representation of that number ("123"). TRIM will also convert the number to
its equivalent string; VALUE will convert a string of digits to its numeric
equivalent.

"Mike K" wrote:

Oh wise ones,
I have two cells that I am comparing. The values come from an array
function that is pulled from a sql server, so the reference cells are not
very editable. Lets call them A1 and A2. I refer to them in B1 and B2 where I
compare them for equality. They look identical, but they do not compare as
true so there must be some leading/trailing spaces. How can I take out the
spaces from B1 and B2 so they compare properly?

Thanks,
Mike


Mike K

Compare two cells from reference cells
 
Thanks, that works beautifully. I forgot about the TRIM function. I've never
had to use it before, but I knew there was something like that to suit my
purpose. They sometimes tinker with the PLC tags, and what was working one
day, may not be the next. Then it's up to me to fix my app- again.

Thanks again,
Mike

"bpeltzer" wrote:

TRIM will removing leading and trailing spaces. Another common cause of
failure to match is a difference between a number (123) and a string
representation of that number ("123"). TRIM will also convert the number to
its equivalent string; VALUE will convert a string of digits to its numeric
equivalent.

"Mike K" wrote:

Oh wise ones,
I have two cells that I am comparing. The values come from an array
function that is pulled from a sql server, so the reference cells are not
very editable. Lets call them A1 and A2. I refer to them in B1 and B2 where I
compare them for equality. They look identical, but they do not compare as
true so there must be some leading/trailing spaces. How can I take out the
spaces from B1 and B2 so they compare properly?

Thanks,
Mike



All times are GMT +1. The time now is 06:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com