Locating largest value and return it's heading from table using excel vba -
v1 v2 v3 1 5 9 b 2 2 6 c 7 8 4
hi experts,
i need support find largest value (whole range) in table , return it's location. example, largest value 9 , result should return v3.
thank you
say have:
.
then:
sub finder() dim tabl range, headr range, mx variant dim wf worksheetfunction, r range set wf = application.worksheetfunction set tbl = range("c5:e7") set headr = range("c4:e4") mx = wf.max(tbl) set r = tbl.find(what:=mx) v = intersect(headr, r.entirecolumn).value msgbox v end sub
edit#1
this version returns concatenation of column header , row id:
sub finder() dim tabl range, headr range, mx variant dim wf worksheetfunction, r range, colr range set wf = application.worksheetfunction set tbl = range("c5:e7") set headr = range("c4:e4") set colr = range("b5:b7") mx = wf.max(tbl) set r = tbl.find(what:=mx) v = intersect(headr, r.entirecolumn).value v = v & " " & intersect(colr, r.entirerow).value msgbox v end sub
Comments
Post a Comment