Search function instead of if statements

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rfr3sh
    SBR Posting Legend
    • 11-07-09
    • 10229

    #1
    Search function instead of if statements
    I am trying to automate my model, and the only thing I can think of is creating if statements

    ie if I type in Wizards in Cell A30 then it will pull the necessary information from the spreadsheet above to calculate what I want it to, the only problem is there are 30 teams in the league so an If statement is kind of tedious

    something like if(A30='Wizards' then B30 = ... etc) but do that 30 times

    I was curious if there is some sort of search function or anything in Excel that would search from A2:A31 for a specific string, and if it is found then apply calculations?

    Or would I have to code this?
  • Maverick22
    SBR Wise Guy
    • 04-10-10
    • 807

    #2
    This screams macro to me.

    Record a macro for this one team.

    Then duplicate for the rest?

    The initial idea i was to. Record a macro, to pull a team. and create a new sheet?
    Then modify the macro to do it for each of the 30 teams?
    You can do w/e model voodoo magic you do.
    Then record another macro to delete them you are done.

    Essentially creating temporary tables.
    Comment
    • xbalto
      SBR High Roller
      • 10-14-10
      • 106

      #3
      vlookup/hlookup
      Comment
      • rfr3sh
        SBR Posting Legend
        • 11-07-09
        • 10229

        #4
        amazing
        Comment
        • Flying Dutchman
          SBR MVP
          • 05-17-09
          • 2467

          #5
          Yeah, vlookup is the cure for a ton of ills.

          Comment
          • Flying Dutchman
            SBR MVP
            • 05-17-09
            • 2467

            #6
            BUT, you got to make sure your lookup list is sorted lowest to highest!!!! most important!

            Comment
            • rfr3sh
              SBR Posting Legend
              • 11-07-09
              • 10229

              #7
              Originally posted by Flying Dutchman
              BUT, you got to make sure your lookup list is sorted lowest to highest!!!! most important!
              what if it is a string? and why is this
              Comment
              • xbalto
                SBR High Roller
                • 10-14-10
                • 106

                #8
                Yeah, vlookup has some strange behavior, and I think the best way to avoid it is to pass "0" or "FALSE" as the fourth argument to vlookup (i.e. as "range_lookup" in VLOOKUP(lookup_value,table_array,col_index_num,range_lookup)). This will make sure it only returns exact matches.
                Comment
                • mminkovski
                  SBR MVP
                  • 06-22-07
                  • 1077

                  #9
                  yes, vlookup returns exact matches when 0 is at the end

                  if you're looking for match in more than 1 cell then concatenate them first
                  Comment
                  • rfr3sh
                    SBR Posting Legend
                    • 11-07-09
                    • 10229

                    #10
                    yeah I had it set to false, and it was returning the correct data in an unsorted list, thanks again
                    Comment
                    SBR Contests
                    Collapse
                    Top-Rated US Sportsbooks
                    Collapse
                    Working...