# IF (ISNA) question

Hi Guys, how do you turn this IFERROR formula into an IF(ISNA)?

=IFERROR(INDEX(Journals!P\$5:P\$1000,MATCH(TRUE,INDEX(Journals!B\$5:B\$1000=B572,0),0)),0)
###### Who is Participating?

Commented:
I like NB_VC's suggestion of using a user-defined function to concatenate the string--but the sorting feature should be added to the UDF. That way, you won't need the array formula.

The UDF below should be pasted on a regular module sheet (just like a macro). It returns the values in the input parameters separated by commas and arranged in ascending order. You can then use it in a worksheet formula like:
=ConcatInOrder(E2,J2,I2,M2,V2)
Function ConcatInOrder(ParamArray vData() As Variant) As String
Dim v As Variant, vSorted As Variant
Dim i As Long, j As Long, n As Long
Dim bSorted As Boolean
Dim s As String, sep As String
sep = ","      'Separator between items in list
ReDim vSorted(1 To UBound(vData))
For Each v In vData
If v <> "" Then
n = n + 1
vSorted(n) = v
End If
Next
If n > 1 Then
For i = 1 To n
bSorted = True
For j = 2 To n
If vSorted(j) < vSorted(j - 1) Then
v = vSorted(j - 1)
vSorted(j - 1) = vSorted(j)
vSorted(j) = v
bSorted = False
End If
Next
If bSorted = True Then Exit For
Next
End If
For i = 1 To n
s = s & sep & vSorted(i)
Next
ConcatInOrder = Mid\$(s, Len(sep) + 1)
End Function
0

EngineerCommented:
=IF(ISNA(MATCH(TRUE,INDEX(Journals!B\$5:B\$1000=B572,0),0)),0,INDEX(Journals!P\$5:P\$1000,MATCH(TRUE,INDEX(Journals!B\$5:B\$1000=B572,0),0)))
0

Commented:
Do you mind to post your sheet here? I want to show you somethings!
0

Commented:
I just found you have some questions, I think this is one question!  I guess you are an accountant (same with me)!

Andrew
0

Commented:
justincut,

I see you are building on/ using solutions provided in previous threads, can you please close those threads if they were met with your satisfaction.
0

Commented:
I am also a bit confused on a previous thread where you provided an ISNA() type formula you asked how to shorten it.  I provided you an IFERROR() solution to do that.  Now you are asking for the reverse again.... I am kind of confused....
0

Commented:
I agree with NB_VC. Perhaps you could give a wider explanation of what you are trying to do. Sometimes it's a good thing to split your requirement in to small chunks but sometimes (including here, I think) it would be beneficial if you try to explain your ultimate aim - there may be better ways than the way you are attempting.

I pointed this out in another thread but this construction:

=INDEX(Journals!P\$5:P\$1000,MATCH(TRUE,INDEX(Journals!B\$5:B\$1000=B572,0),0))

is almost always unnecessary. If you are looking up B572 in column B and returning a result from column P then a basic INDEX/MATCH to do that would be like this

=INDEX(Journals!P\$5:P\$1000,MATCH(B572,Journals!B\$5:B\$1000,0))

and if you want you can make that a VLOOKUP like this:

=VLOOKUP(B572,Journals!B\$5:P\$1000,15,0)

Now you can use ISNA round either of those, or even IFERROR, e.g. ISNA in conjunction with VLOOKUP

=IF(ISNA(VLOOKUP(B572,Journals!B\$5:P\$1000,15,0)),"",VLOOKUP(B572,Journals!B\$5:P\$1000,15,0))

regards, barry
0

Commented:
me too
0

Commented:
OK, sorry Justin, I was a little slow - you're using that construction because of the 255 character limit, I forgot about your previous thread.

...but that in itself is a good reason for a little more context - if you explain (briefly) what you are doing and why then you won't get idiots like me suggesting you change the formula for a different one!

So why ISNA rather than IFERROR, are you doing this in excel 2003 or is there another reason?

regards, barry
0

Commented:
But, the isna() and iserror() really is some difference in the accounting point of view.
0

Commented:
In the accounting point of view, isna() is not found (not included any errors), iserror() is included isna() and errors.
0

Author Commented:
Hi Guys, the reason why I need an ISNA() instead of an ISERROR() is because I need to retrieve a "VALUE#" message when there is a Vlookup not working. The problem is the Vlookup Cell on one day has a Value with several trade IDs on it (eg. 5678910, 2467891, 5734789) and on the next day, due to  a system bug, the sequence of Trade IDs changes to (2467891, 5678910, 5734789) so although the contents of the cell is the same, its in a different sequence so the Vlookup does not work. If I use an Iserror, it hides the fact there is a problem whereas if I use ISNA, it shows VALUE# so I can see there is a problem. Has anyone got any idea how to make this cell of trade ids go in a numerical sequence so the Vlookup works. I am an accountant at a bank and I have to do a Rec comparing trades every day so I do a vlookup on the previous day to see if there is a break
0

Commented:
As an example, assume that cell with multiple ID's in it is cell A9.

First, we will need to add a User Defined Function, for concatenating multiple values.

So go to the VB editor (Alt+F11), then Insert Module and paste this UDF:

Function aconcat(a As Variant, Optional sep As String = "") As String
' Harlan Grove, Mar 2002
Dim y As Variant

If TypeOf a Is Range Then
For Each y In a.Cells
aconcat = aconcat & y.Value & sep
Next y
ElseIf IsArray(a) Then
For Each y In a
aconcat = aconcat & y & sep
Next y
Else
aconcat = aconcat & a & sep
End If

aconcat = Left(aconcat, Len(aconcat) - Len(sep))
End Function

Then this formula will convert that string of ID's to a numerically ascending sequence in one step:

=aconcat(SMALL(TRIM(MID(SUBSTITUTE(A9,",",REPT(" ",100)),1+(100*(ROW(INDIRECT("1:"&LEN(A9)-LEN(SUBSTITUTE(A9,",",""))+1))-1)),100))+0,ROW(INDIRECT("1:"&LEN(A9)-LEN(SUBSTITUTE(A9,",",""))+1))),", ")

This will need to be confirmed with CTRL+SHIFT+ENTER.

The only issue is that it will need to be included at each function in your formula that will need to reference this to do the look up.

You can also place this formula in another cell on it's own, maybe adjacent to the original, and re-write the VLOOKUPs to reference that new cell with the sorted strings.

Will that help?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.