excel vba - arrays vba - type mismatch: array or user-defined type expected -
i having issue passing array sub (receiving type mismatch: array or user-defined type expected). have worked array structures in other languages , must missing here in vba since can't work. have posted code snippets below comment:
private sub x() dim ssn_vals(1 9) string dim ssn_cells(1 9) string 'define employee object dim emp employee 'create new employee foreach row set emp = new employee 'ssn values ssn_vals(1) = cell.offset(0, 60) ssn_vals(2) = cell.offset(0, 61) ssn_vals(3) = cell.offset(0, 62) ssn_vals(4) = cell.offset(0, 63) ssn_vals(5) = cell.offset(0, 64) ssn_vals(6) = cell.offset(0, 65) ssn_vals(7) = cell.offset(0, 66) ssn_vals(8) = cell.offset(0, 67) ssn_vals(9) = cell.offset(0, 68) 'ssn cell addresses ssn_cells(1) = cell.offset(0, 60).address ssn_cells(2) = cell.offset(0, 61).address ssn_cells(3) = cell.offset(0, 62).address ssn_cells(4) = cell.offset(0, 63).address ssn_cells(5) = cell.offset(0, 64).address ssn_cells(6) = cell.offset(0, 65).address ssn_cells(7) = cell.offset(0, 66).address ssn_cells(8) = cell.offset(0, 67).address ssn_cells(9) = cell.offset(0, 68).address emp.setssn = ssn_vals emp.setssn_cells = ssn_cells 'validate ssn emp.validatessn (ssn_vals) end sub
i have sub defined inside employee class
'validate ssn public sub validatessn(ssn() variant) dim integer 'dim orig_array(1 9) variant dim multipler_array(1 9) integer dim summation_array(1 9) integer multipler_array(1) = 1 multipler_array(2) = 2 multipler_array(3) = 1 multipler_array(4) = 2 multipler_array(5) = 1 multipler_array(6) = 2 multipler_array(7) = 1 multipler_array(8) = 2 multipler_array(9) = 1 if me.getsinort = "sin" = lbound(ssn(i)) ubound(ssn(i)) summation_array(i) = (int(ssn(i)) * int(multipler_array(i))) debug.print summation_array(i) next else end if end sub
any suggestions on how fix trivial thing appreciated. in advance, michael
you using cell range, have not dim'ed or set it. there may other problems
Comments
Post a Comment