excel - Sum values between a colored range -
i'm trying sum range of values between 2 cells same interior color. output should directed cell. objective user define starting cell , cell output , function should run until changes column or finds cell same interior function.
this i've done, gets #value error every time. notice haven't added rule when column shifts stop calculation, , sum cause of error , i'm not sure.
function countccolor(range_data range, criteria range, valx range) long dim datax range dim xcolor long xcolor = criteria.interior.colorindex valx = 0 each datax in range_data if datax.interior.colorindex = xcolor exit end if if datax.interior.colorindex <> xcolor valx = datax.value end if next datax end function
to sum of cells values between colored cells can use this:
function countccolor(range_data range, criteria range) dim datax range, countval, x% each datax in range_data if datax.interior.color = criteria.interior.color x = x + 1 end if if datax.interior.color <> criteria.interior.color , x = 1 countval = countval + datax.value end if next datax countccolor = countval end function
output
to count of cells between colored cells can use this:
function countccolor(range_data range, criteria range) dim datax range, countval, x% each datax in range_data if datax.interior.color = criteria.interior.color x = x + 1 end if if datax.interior.color <> criteria.interior.color , x = 1 countval = countval + 1 end if next datax countccolor = countval end function
output
Comments
Post a Comment