excel - Use cell value as -
i'm trying use value in cell f2 maximum value of range selection within larger range of numbers.
i've gotten far below, getting compile error: variable not defined.
option explicit sub selectbyvalue(rng1 range, minimunvalue double, maximumvalue double) dim myrange range dim cell object 'check every cell in range matching criteria. each cell in rng1 if cell.value >= minimunvalue , cell.value <= maximumvalue if myrange nothing set myrange = range(cell.address) else set myrange = union(myrange, range(cell.address)) end if end if next 'select new range of matching criteria myrange.select end sub sub callselectbyvalue() 'call macro , pass required variables it. 'in line below, change range, minimum value, , maximum value needed call selectbyvalue(range("a2:a41"), 1, range(f2).value) end sub
in line:
call selectbyvalue(range("a2:a41"), 1, range(f2).value)
f2 needs quoted. it's not variable code can see:
call selectbyvalue(range("a2:a41"), 1, range("f2").value)
Comments
Post a Comment