lib/soroban/functions/vlookup.rb in soroban-0.2.0 vs lib/soroban/functions/vlookup.rb in soroban-0.3.0

- old
+ new

@@ -1,10 +1,13 @@ # Return a value from the supplied range by searching the first column for the # supplied value, and then reading the result from the matching row. Soroban::define :VLOOKUP => lambda { |value, range, col, inexact| fc, fr, tc, tr = Soroban::getRange(range) i = walk("#{fc}#{fr}:#{fc}#{tr}").find_index(value) - return nil if i.nil? - (0...i).each { fr.next! } - (1...col).each { fc.next! } - eval("@#{fc}#{fr}.get") + if i.nil? + nil + else + (0...i).each { fr.next! } + (1...col).each { fc.next! } + eval("@#{fc}#{fr}.get") + end }