Is it possible to add a check of data validity in the range r?

Juggler_IN

Active Member
Joined
Nov 19, 2014
Messages
358
Office Version
  1. 2003 or older
Platform
  1. Windows
I need help on a UDF shared by [MENTION]shg[/MENTION]

HTML:
https://www.mrexcel.com/forum/excel-questions/499657-kendall-tau-test.html

Is it possible to add a check of data validity in the range r. For example, if the data is:

[TABLE="class: cms_table, width: 128"]
<tbody>[TR]
[TD][X][/TD]
[TD][Y][/TD]
[/TR]
[TR]
[TD="align: right"]12[/TD]
[TD="align: right"]77[/TD]
[/TR]
[TR]
[TD="align: right"]15[/TD]
[TD="align: right"]98[/TD]
[/TR]
[TR]
[TD="align: right"]24[/TD]
[TD].[/TD]
[/TR]
[TR]
[TD="align: right"]12[/TD]
[TD="align: right"]93[/TD]
[/TR]
[TR]
[TD="align: right"]26[/TD]
[TD="align: right"]92[/TD]
[/TR]
</tbody>[/TABLE]


Currently function fails.

Can the code be modified to ignore the 3rd pair (and any other subsequent such pairs) and compute with the remaining 4 pairs?
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hi Juggler,
what I would do is first clean the input data and than feed it into the function. Something like this:
Code:
Function KendallTau(r As Range) As Double
    
    Dim cleanr() As Variant
    
    rwn = 1
    For rw = 1 To r.Rows.Count
        If IsNumeric(r(rw, 1).Value) And IsNumeric(r(rw, 2).Value) Then
            ReDim Preserve cleanr(1 To 2, 1 To rwn)
            cleanr(1, rwn) = r(rw, 1).Value
            cleanr(2, rwn) = r(rw, 2).Value
            rwn = rwn + 1
        End If
    Next rw
    cleanr1 = Application.Transpose(cleanr)
    
    KendallTau = dKendallTau(cleanr1)

End Function
Cheers,
Koen
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top