Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 137
Default incorrect output of if formula

I have two cells with values which were macro auto copied from other cells by
copy - paste special €“ value, I have a =if(A1=A2,"yes","no") formula in third
cell to compare these two cells. From time to time the output of formula
gives inccorrect answer, but if I copy the first cell to the second cell
again manually using copy €“ paste function, the third cell gives the right
answer. Any idea why and how to correct this please?
Rgds

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,104
Default incorrect output of if formula

Are you comparing real numbers (numbers with decimal places)?; if so, it is
possible they display the same but are very slightly different.
Try =if(ABS(A1-A2)<1E-10,"yes","no")
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email


"Seeker" wrote in message
...
I have two cells with values which were macro auto copied from other cells
by
copy - paste special - value, I have a =if(A1=A2,"yes","no") formula in
third
cell to compare these two cells. From time to time the output of formula
gives inccorrect answer, but if I copy the first cell to the second cell
again manually using copy - paste function, the third cell gives the right
answer. Any idea why and how to correct this please?
Rgds


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default incorrect output of if formula

Check whether there is a space in one of the cells

Try the below..If it works then there is a space in one of the cells
=IF(TRIM(A1)=TRIM(A2),"yes","no")

or try
=CODE(A1)
If it returns a number insteadof #value there is a character there in one of
the cell.

If this post helps click Yes
---------------
Jacob Skaria


"Seeker" wrote:

I have two cells with values which were macro auto copied from other cells by
copy - paste special €“ value, I have a =if(A1=A2,"yes","no") formula in third
cell to compare these two cells. From time to time the output of formula
gives inccorrect answer, but if I copy the first cell to the second cell
again manually using copy €“ paste function, the third cell gives the right
answer. Any idea why and how to correct this please?
Rgds

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default incorrect output of if formula

Oops. I thought you were having the formula incorrect when you have nothing
in it.

If text checkout for space.
Or
If numerics checkout for the exact value...


If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Check whether there is a space in one of the cells

Try the below..If it works then there is a space in one of the cells
=IF(TRIM(A1)=TRIM(A2),"yes","no")

or try
=CODE(A1)
If it returns a number insteadof #value there is a character there in one of
the cell.

If this post helps click Yes
---------------
Jacob Skaria


"Seeker" wrote:

I have two cells with values which were macro auto copied from other cells by
copy - paste special €“ value, I have a =if(A1=A2,"yes","no") formula in third
cell to compare these two cells. From time to time the output of formula
gives inccorrect answer, but if I copy the first cell to the second cell
again manually using copy €“ paste function, the third cell gives the right
answer. Any idea why and how to correct this please?
Rgds

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 793
Default incorrect output of if formula

This might happen when
1. you are comparing numbers which might be different due to the numbers
after the decimal. You may increase the display of numbers after the decimal
to see
2. there are spaces after the values

use
=Len(A1)
and
=Len(A2)
to see whether they are same or different

You may try
=IF(LEFT(A1,4)=LEFT(A2,4),"Yes","No")
to compare first four characters of the values



"Seeker" wrote:

I have two cells with values which were macro auto copied from other cells by
copy - paste special €“ value, I have a =if(A1=A2,"yes","no") formula in third
cell to compare these two cells. From time to time the output of formula
gives inccorrect answer, but if I copy the first cell to the second cell
again manually using copy €“ paste function, the third cell gives the right
answer. Any idea why and how to correct this please?
Rgds



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 137
Default incorrect output of if formula

Hi Bernard,
Thanks for your idea. Problems arised was nothing related to the decimal
places because I extract the figure before decimal for compariation.
Rgds

"Bernard Liengme" wrote:

Are you comparing real numbers (numbers with decimal places)?; if so, it is
possible they display the same but are very slightly different.
Try =if(ABS(A1-A2)<1E-10,"yes","no")
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email


"Seeker" wrote in message
...
I have two cells with values which were macro auto copied from other cells
by
copy - paste special - value, I have a =if(A1=A2,"yes","no") formula in
third
cell to compare these two cells. From time to time the output of formula
gives inccorrect answer, but if I copy the first cell to the second cell
again manually using copy - paste function, the third cell gives the right
answer. Any idea why and how to correct this please?
Rgds



  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 137
Default incorrect output of if formula

Hi Jacob,
I dont know how to use the =CODE(), but the trimming formula works. Since
pasted value most of the time (but not definite?) showing €œthe number in cell
is formatted as text or preceded by an apostrophe€, by using =trim(), this
problem is removed and cells are in the same format.
Rgds


"Jacob Skaria" wrote:

Check whether there is a space in one of the cells

Try the below..If it works then there is a space in one of the cells
=IF(TRIM(A1)=TRIM(A2),"yes","no")

or try
=CODE(A1)
If it returns a number insteadof #value there is a character there in one of
the cell.

If this post helps click Yes
---------------
Jacob Skaria


"Seeker" wrote:

I have two cells with values which were macro auto copied from other cells by
copy - paste special €“ value, I have a =if(A1=A2,"yes","no") formula in third
cell to compare these two cells. From time to time the output of formula
gives inccorrect answer, but if I copy the first cell to the second cell
again manually using copy €“ paste function, the third cell gives the right
answer. Any idea why and how to correct this please?
Rgds

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
sorting atuofilter incorrect output Big Mac Excel Discussion (Misc queries) 5 October 24th 07 12:35 PM
formula output durebel1 Excel Worksheet Functions 1 September 23rd 07 11:20 AM
How do I use a referenced cell's formula instead of formula output? Farrelltw Excel Worksheet Functions 0 February 10th 06 05:00 PM
add text to end of formula output mgdarkman Excel Discussion (Misc queries) 2 December 9th 05 03:51 AM
formula for custom output TUNGANA KURMA RAJU Excel Discussion (Misc queries) 0 November 15th 05 04:36 AM


All times are GMT +1. The time now is 09:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"