+ Reply to Thread
Results 1 to 9 of 9

Need to do vlookup based on whether cell contains @ or not

  1. #1
    Registered User
    Join Date
    10-03-2015
    Location
    Massachusetts
    MS-Off Ver
    Office 2013
    Posts
    4

    Need to do vlookup based on whether cell contains @ or not

    I am making a worksheet that contains a column for one team and another for its opponent. The second column displays either the other team or @team. In the third column, I want to do a vlookup. The column I need to lookup depends on whether the second column contains "@" or not.

    Ideally, I want it to check the cell for the @. If it contains the symbol, it would use the next 3 characters for a Vlookup. If there is no @ present, it would do a vlookup from the other cell. The teams in both columns are all abbreviated to 2-3 characters.
    A1 B1 C1
    TEAM TEAM VLOOKUP (from A1)
    TEAM @TEAM VLOOKUP (TEAM in B1)
    What formula could I use? Please let me know.

    Thanks.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Need to do vlookup based on whether cell contains @ or not

    Hi, welcome to the forum

    maybe something like this?

    =vlookup(IF(LEFT(B1,1)="@",A1,B1),the-rest=of=your=formula,,,,,,,,,,,,,,,,,,,,,,

    If you still have a problem, upload a small (clean) sample workbook (not a pic) of what you are working with, and what your expected outcome would look like.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    10-03-2015
    Location
    Massachusetts
    MS-Off Ver
    Office 2013
    Posts
    4

    Re: Need to do vlookup based on whether cell contains @ or not

    Quote Originally Posted by FDibbins View Post
    Hi, welcome to the forum

    maybe something like this?

    =vlookup(IF(LEFT(B1,1)="@",A1,B1),the-rest=of=your=formula,,,,,,,,,,,,,,,,,,,,,,

    If you still have a problem, upload a small (clean) sample workbook (not a pic) of what you are working with, and what your expected outcome would look like.
    You were close. You actually had the A1 and B1 switched, but I also had to add another formula in place of the B1 to search without the @. Here's the final formula:
    =VLOOKUP(IF(LEFT(B1,1)="@",REPLACE(B1,1,1,""),A1),'Park Factor'!$M$4:$P$33,4,FALSE)

    Now I just have to add another vlookup using the results of this formula. How fun.

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Need to do vlookup based on whether cell contains @ or not

    Now I just have to add another vlookup using the results of this formula. How fun.
    what exactly are you trying to achieve here?

    Perhaps if you upload a small (clean) sample workbook (not a pic) of what you are working with, and what your expected outcome would look like.

  5. #5
    Registered User
    Join Date
    10-03-2015
    Location
    Massachusetts
    MS-Off Ver
    Office 2013
    Posts
    4

    Re: Need to do vlookup based on whether cell contains @ or not

    Quote Originally Posted by FDibbins View Post
    what exactly are you trying to achieve here?

    Perhaps if you upload a small (clean) sample workbook (not a pic) of what you are working with, and what your expected outcome would look like.
    I'm working on spreadsheets to use for the different fantasy sports. I'm working on the MLB one right now. I know, it's the end of the season. Hopefully the playoffs take awhile I guess.

    The cells are filled with the basic player data, which includes the player's team and the opponents team. If the game is played at the opponent's stadium, the team has an "@" before the team abbreviation. Each stadium the teams play at has it's own park factor. The purpose of the formula you helped me with is to lookup the stadium name of where the game will be played. The next vlookup uses the stadium name to pull the actual park factor from a different list of data. This formula I already know what to enter to make it work. I'm just making the first formula a nested formula in the second vlookup. There isn't a shorter way to do two vlookups using the data from one for the other is there? This is what my final formula looks like:

    =VLOOKUP(VLOOKUP(IF(LEFT(G4,1)="@",REPLACE(G4,1,1,""),D4),'Park Factor'!$M$4:$P$33,4,FALSE),'Park Factor'!$C$4:$I$33,2,FALSE)

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Need to do vlookup based on whether cell contains @ or not

    Off the top of my head, perhaps you could combine the source tables, so you just do 1 VL?

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Need to do vlookup based on whether cell contains @ or not

    Please note that if you post on another forum, you are required to provide a link to that post.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    http://www.mrexcel.com/forum/excel-q...s-%40-not.html

  8. #8
    Registered User
    Join Date
    10-03-2015
    Location
    Massachusetts
    MS-Off Ver
    Office 2013
    Posts
    4

    Re: Need to do vlookup based on whether cell contains @ or not

    Quote Originally Posted by FDibbins View Post
    Off the top of my head, perhaps you could combine the source tables, so you just do 1 VL?
    Not sure. The park factors change regularly, so I end up copying and pasting the new data to the same location in the workbook. I'd love to use the import web data feature, but the webpage doesn't give me the box to click so I can download it automatically. I have it setup with a table of team abbreviations, team names, nicknames, and stadium names. The other table contains all of the park factor data with the identifier being the stadium name. The lookup uses the team abbreviation, but the table I copy and paste doesn't include it.

    I did post on another site outside of this one because I didn't know if/when I would get a response through this site. I've made lots of postings on forums where I never received a response, so I'm not putting all my eggs in one basket when I don't know if the site is going to help me or not. I recognized you for your effort though and showed it by commenting in your reputation section. And the discussion is continuing on if there are better options than what I'm using.

    http://www.mrexcel.com/forum/excel-q...s-%40-not.html

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Need to do vlookup based on whether cell contains @ or not

    Dont get me wrong, Im not saying you should not post on other forums, just that if you do (and I can understand why you would), you need to post a link here to that thread. Most other forums all have the same requirement, it saves members from spending time and effort of a question that may already have been solved on another forum

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Concatenate cell based on vlookup cell reference
    By tlc1980 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-14-2014, 04:06 PM
  2. [SOLVED] vlookup based on cell value
    By sudharshan86 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-19-2014, 04:17 AM
  3. Auto Populate cell based on Drop Down list in another cell (VLookup)
    By alialmoore in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-27-2013, 04:07 PM
  4. Replies: 6
    Last Post: 09-04-2012, 10:35 AM
  5. VLOOKUP based on cell content
    By garyi in forum Excel General
    Replies: 17
    Last Post: 02-27-2012, 09:44 PM
  6. vlookup based on cell color
    By kolette in forum Excel General
    Replies: 2
    Last Post: 06-23-2009, 02:23 PM
  7. Vlookup Based on Cell Date
    By Kurt_v in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-24-2006, 12:04 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1