2-DRange -> Array -> 2D-Range with UDF Excel 2007 VBA -


i'm trying create udf has 2d-range input, resizes it, adjusts 1 of values , has new 2d-range output. important have range output since ranges used other functions. unfortunately other function not recognize new 2d-range range.


function func1(structure range) variant  = 3 dim temp1 range dim temp2 range set temp1 = structure.resize(i, 3)  dim arr1() redim arr1(1 i, 1 3) arr1 = temp1 arr1(2, 2) = 100  func1 = arr1  end function 

function func2(inputarray)  func2 = inputarray.rows.count  end function 

so - function func2(func1(structure)) not work. should give out number of rows in new 2d-range.

will please?

i'm using excel 2007

tim williams , kazjaw correct, might consider using approach. however, have possible solution , code below. note approach slow , must strict exception handling.

option explicit  function func1(structure range) range     dim tempws worksheet 'needed create range     dim temp1 range      'resized input range     dim temp2 range      'why needed?     dim arr1 range       'range returned     dim integer        '?      'add temporary worksheet end     set tempws = thisworkbook.worksheets.add(, _         thisworkbook.worksheets(thisworkbook.worksheets.count))     = 3      set temp1 = structure.resize(i, 3)      tempws          'set temporary range , existing values         set arr1 = tempws.range(.cells(1, 1), .cells(i, 3))     end      arr1.value = temp1.value      arr1(2, 2) = 100      set func1 = arr1      'clean     set temp1 = nothing     set temp2 = nothing     set arr1 = nothing     set tempws = nothing  end function   sub test()     dim getrange range     set getrange = func1(range("a1:c3"))     thisworkbook.worksheets(1).range("d1:f3").value = getrange.value      'you need delete temporary worksheet     application.displayalerts = false     getrange.worksheet.delete     application.displayalerts = true     set getrange = nothing end sub 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -