Excel/VBA: Cannot get Variant/Boolean to return (should be trivial) -


i cannot function return values output column in excel:

to overcome intense lookup tables , speed computation, using pivot table slicers output row numbers filtering. these rows need converted column of true/false cells large table want perform more calculations. avoid lookups or matching need step through list of rows , turn cells "true" in output vector.

function includedinslicer(input_range variant) variant  dim n long, j long, r long n = input_range.height ' height of column of reference values ' every row in input_range contains row number in output should true ' other rows should false  dim output_range variant redim output_range(1 300000) ' covers maximum number of rows  ' initialise rows false j = 1 300000     output_range(j) = false next j  ' set rows listed in reference true j = 1 n     r = input_range(j).value     if r = 0 ' if r=0 beyond end of reference table , have captured blank rows         exit ' exit, avoid outside-of-array errors     else         output_range(r) = true     end if     'end if next j  ' return results excel ' last bit not return values excel includedinslicer = output_range end function 

i know should trivial somehow has vexed me literally hours. please help! thank in advance!

edit: found issue!

first, thank pointing out difference between height , rows.count not aware of this.

unfortunately, still left me same error in final cell output (#value). luckily in meantime tried processing via matlab instead , when passing results got same error. allowed me narrow down problem , tracked error ... (drum roll) ... vba's 2^16 limit array size. table has close 2^18 rows causes error.

input_range.height refers literal height in pixels of range. try instead input_range.rows.count number of rows in range.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -