excel - Identify missing values from array -


i striving create function in vba calculates number of missing values in each column of matrix of nxn dimensions.

each column should contain numbers 1 n once. if not case want function state how many values missing. example in column of 4x4 matrix (1,2,1,3) there 1 missing value 4, , function should return value 1, 1 missing value.

i new vba , no means master, have done far...

function calccost(sol() integer, n integer) integer  dim arrayoftruth(1 n) boolean        row = 1 n         = 1 n             if probmatrix(column, row) =                 arrayoftruth(i) = true      cost = 0     = 1 n         if arrayoftruth(i) = true             cost = cost + 1 

assuming requirement of square range of cells supersedes description of 'matrix's' values, i'm not sure why array needed @ all.

function calccost(rtopleft range, n long)     dim c long, r long      c = 1 n         if not cbool(application.countif(rtopleft.resize(n, n), c)) _             r = r + 1     next c     calccost = r  end function 

syntax:

    =calccost(<top left corner of desired range>, <number of cells both right , down>)

example:

=calccost(e9, 18) 

the above implementation written as,

=18-sumproduct(--sign(countif(offset(e9,0,0,18,18), row(1:18)))) 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -