Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Supress #Ref! error

The formula below finds the second occurence of a value in a table and reurns
another value and works OK. The problem is that there isn't always a second
occurence and it returns a #REF! error whicj looks a mess. Is there any way
of supressing the error?

=INDEX(Sheet1!$A2:Sheet1!$F50000,SMALL(IF(Sheet1!$ A2:Sheet1!$F50000=$A5,ROW(Sheet1!$A2:Sheet1!$F5000 0)-ROW(Sheet1!$A2)+1,ROW(Sheet1!$F50000)+1),2),2)

Mike
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 751
Default Supress #Ref! error

On May 2, 4:42 pm, Mike H wrote:
The formula below finds the second occurence of a value in a table and reurns
another value and works OK. The problem is that there isn't always a second
occurence and it returns a #REF! error whicj looks a mess. Is there any way
of supressing the error?

=INDEX(Sheet1!$A2:Sheet1!$F50000,SMALL(IF(Sheet1!$ A2:Sheet1!$F50000=$A5,ROW(Sheet1!$A2:Sheet1!$F5000 0)-ROW(Sheet1!$A2)+1,ROW(Sheet1!$F50000)+1),2),2)

Mike


Mike,
the offending part is the call to SMALL, which might return an error:
SMALL(IF(Sheet1!$A2:Sheet1!$F50000=$A5,ROW(Sheet1! $A2:Sheet1!$F50000)-
ROW(Sheet1!$A2)+1,ROW(Sheet1!$F50000)+1),2)

You need to trap this expression:
=IF(ISERROR(SMALL(IF(Sheet1!$A2:Sheet1!$F50000=$A5 ,ROW(Sheet1!
$A2:Sheet1!$F50000)-ROW(Sheet1!$A2)+1,ROW(Sheet1!$F50000)+1),
2)),"",INDEX(Sheet1!$A2:Sheet1!$F50000,SMALL(IF(Sh eet1!$A2:Sheet1!
$F50000=$A5,ROW(Sheet1!$A2:Sheet1!$F50000)-ROW(Sheet1!
$A2)+1,ROW(Sheet1!$F50000)+1),2),2))

HTH
Kostis Vezerides

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 68
Default Supress #Ref! error

You can select all cells, use Format/Conditional Formatting, change "Cell
Value Is" to "Formula Is", then enter this:
=ISERROR(A1) then click the format button, Font tab, select a white font.
Bob Umlas
Excel MVP
"Mike H" wrote in message
...
The formula below finds the second occurence of a value in a table and
reurns
another value and works OK. The problem is that there isn't always a
second
occurence and it returns a #REF! error whicj looks a mess. Is there any
way
of supressing the error?

=INDEX(Sheet1!$A2:Sheet1!$F50000,SMALL(IF(Sheet1!$ A2:Sheet1!$F50000=$A5,ROW(Sheet1!$A2:Sheet1!$F5000 0)-ROW(Sheet1!$A2)+1,ROW(Sheet1!$F50000)+1),2),2)

Mike


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,231
Default Supress #Ref! error

vezerid wrote...
Mike H wrote:
The formula below finds the second occurence of a value in a table and reurns
another value and works OK. The problem is that there isn't always a second
occurence and it returns a #REF! error whicj looks a mess. Is there any way
of supressing the error?

....

While #N/A, #VALUE!, #DIV/0!, #NUM! and #NULL! errors can be annoying,
#REF! and #NAME? errors usually highlight serious logic errors.
Masking these two errors is usually a bad idea.

the offending part is the call to SMALL, which might return an error:
SMALL(IF(Sheet1!$A2:Sheet1!$F50000=$A5,ROW(Sheet1 !$A2:Sheet1!$F50000)-
ROW(Sheet1!$A2)+1,ROW(Sheet1!$F50000)+1),2)


First, while Sheet1!$A2:Sheet1!$F50000 is syntactically valid, it
should be rewritten as a single range reference rather than a range
expression, i.e., as Sheet1!$A2:$F50000.

For the OP: do you mean to search all 6 columns in Sheet1!A2:F50000
for matches against A5 or just Sheet1!A2:A50000?

For vezerid: testing is good. Testing would have shown that this SMALL
call would NEVER return errors because the IF call ALWAYS returns
49999 numeric values. Testing would have shown that the problem occurs
when there are fewer than two values in Sheet1!A2:F50000 equal to A5,
in which case the SMALL call would return ROW(Sheet1!$F50000)+1, or
50001, with is NOT an error value itself but IS greater than the max
row index of Sheet1!A2:F50000.

As I said above, #REF! is almost always due to serious logic errors.

You need to trap this expression:
=IF(ISERROR(SMALL(IF(Sheet1!$A2:Sheet1!$F50000=$A 5,ROW(Sheet1!
$A2:Sheet1!$F50000)-ROW(Sheet1!$A2)+1,ROW(Sheet1!$F50000)+1),2)),"",
INDEX(Sheet1!$A2:Sheet1!$F50000,SMALL(IF(Sheet1!$ A2:Sheet1!$F50000=$A5,
ROW(Sheet1!$A2:Sheet1!$F50000)-ROW(Sheet1!$A2)+1,
ROW(Sheet1!$F50000)+1),2),2))


Trapping the cause of the error is necessary, but there are shorter,
narrower, more efficient and (why not?) correct traps.

=IF(COUNTIF(Sheet1!$A2:$F50000,$A5)<2,"",INDEX(She et1!$A2:$F50000,
SMALL(IF(Sheet1!$A2:$F50000=$A5,ROW(Sheet1!$A2:She et1!$F50000)
-ROW(Sheet1!$A2)+1),2),2))

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
Supress (blank) in pivottable wacNTN Excel Discussion (Misc queries) 1 September 28th 06 10:19 PM
how do I supress text in a column? Supress Repeating values in a column Setting up and Configuration of Excel 1 November 16th 05 11:37 PM
Supress Scientific Numbers?? Sam New Users to Excel 2 August 11th 05 08:40 PM
#div/0! how do i supress? vipa2000 Excel Worksheet Functions 5 July 31st 05 08:34 PM
Supress error message Jim Anderson Excel Discussion (Misc queries) 3 December 1st 04 12:55 AM


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

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

About Us

"It's about Microsoft Excel"