VBA Excel object required passing string array variable -
i attempting pass array of strings function variable , getting '424 object required' error when try compare values in array values in given cell. new vba may simple syntax error cannot seem figure out. here's code:
method being called:
sub initializecharts() 'set's array checking data names in social groups dim socialarray variant socialarray = array("chores", "meat & potatos", "work", "wind down", "reward") '... call chartlogic(range("'activitytracker'!b12"), range("'groups'!f4"), socialarray) end sub
chartlogic method:
sub chartlogic(datacell range, tablecell range, socialarray variant) dim temp double dim count integer '... 'loops through table , looks social cells same name, adding them chart until isempty(datacell) count = lbound(socialarray) ubound(socialarray) if socialarray(count).value = datacell.value '<---error here temp = socialcell.offset(count, 0).value socialcell.offset(count, 0).value = temp + datacell.offset(0, 4).value end if next set datacell = datacell.offset(1, 0) loop end sub
thanks in advance!
as andrew pointed out - socialarray(count).value = cause error because it's variant. can store local variable this.
arrval = socialarray(count)
for count = lbound(socialarray) ubound(socialarray) arrayval = socialarray(count) if arrayval = datacell.value '<---error here temp = socialcell.offset(count, 0).value socialcell.offset(count, 0).value = temp + datacell.offset(0, 4).value end if next
or take off .value it's not cell , not worksheet object variant.
if socialarray(count) = datacell.value