VBA, Excel Error 'object required' when passing an array as a variable -


i have 2 vba procedures 1 building array pass another. however, when first procedure run excel error window pops saying 'object required'. here code have. cannot seem find causing error.

sub determineload()  worksheets("gear").activate  dim row_src string dim strt_row string dim col_storage string dim arr() string dim alength integer  row_src = "c" strt_row = "9" col_storage = "b"  range(row_src + strt_row).activate  while not isempty(range(col_storage + active.row))     if not isempty(activecell)         if activecell.value             alength = ubound(arr) + 1             redim arr(0 alength)             arr(alength) = string(activecell.column, activecell.row)         end if     end if     activecell.offset(0, 1).activate wend  determineweight arr  end sub sub determineweight(paramarray arr() variant)  worksheets("gear").activate  dim weight_lb_trgtcell string dim weight_oz_trgtcell string dim volume_cuin_trgtcell string dim volume_liter_trgtcell string dim col_oz string dim col_lb string dim weight_lb double dim weight_oz double dim oz_to_pound integer dim row_src string dim src_range range  weight_lb_trgtcell = "h4" weight_oz_trgtcell = "i4"  col_oz = "h" col_lb = "i" weight_lb = 0       ' 0 out `weight_lb` weight_oz = 0       ' 0 out `weight_oz` oz_to_pound = 16    ' 16 ounces 1 pound  'get sum of weights (pounds, ounces) n = lbound(arr) ubound(arr)      src_range = range(arr(n))      src_row = src_range.row     weight_oz = weight_oz + range(col_oz + src_row).value     weight_lb = weight_lb + range(col_lb + src_row).value  next n  'convert pounds weight_lb = weight_lb + int(weight_oz / oz_to_pound) weight_oz = weight_oz - ((weight_oz / oz_to_pound) * oz_to_pound)  range(weight_lb_trgtcell) = weight_lb range(weight_oz_trgtcell) = weight_oz  end sub 

why need vba this? put formula in cell h4 (leftover ounces):

=mod(sumif(c9:c1000,"<>",h9:h1000),16) 

and formula in cell i4 (total pounds):

=sumif(c9:c1000,"<>",i9:i1000)+int(sumif(c9:c1000,"<>",h9:h1000)/16) 

adjust ranges suit. if need pick new rows come in or removed, use dynamic named range.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -