+ Reply to Thread
Results 1 to 5 of 5

What am I doing wrong in this if statement?

  1. #1
    Registered User
    Join Date
    04-01-2016
    Location
    Houston
    MS-Off Ver
    2016
    Posts
    4

    What am I doing wrong in this if statement?

    =IF(D1<1,INDEX('Story Event Lookup'!$D$2:$D$300,MATCH('Story Events'!$E$2,'Story Event Lookup'!$B$2:$B$300,0)),INDEX('Story Event Lookup'!$D$2:$D$300,MATCH('Story Events'!$D$1,'Story Event Lookup'!$A$2:$A$300,0)))

    no matter what value is in D1 it does the index from E2. I checked a simple if(d1<1,"true","false") and it returns true and false correctly but when I use the index codes it always does the true.

    Both index codes work when not in the if statement by themselves.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,099

    Re: What am I doing wrong in this if statement?

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? However, please give us an indication of the approximate number of rows of data you want the solution to work with (100, 1000, 100,000 or whatever). Please don't attach a picture of an Excel sheet (no-one will want to re-type all your stuff before starting).

    1. It does NOT have to be your real sheet - mock up a SAMPLE if you need to. But not 1000's of rows!!! It makes manual checking so tedious. Whatever you do... make sure that all confidential information is removed first!!

    2. Make sure that your sample data are truly REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    3. Make sure that your desired solution is also shown (mock up the results manually).

    4. Try to avoid using merged cells. They cause lots of problems!

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,099

    Re: What am I doing wrong in this if statement?

    I don't see the problem here. I have adapted you formula for a single sheet.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    04-01-2016
    Location
    Houston
    MS-Off Ver
    2016
    Posts
    4

    Re: What am I doing wrong in this if statement?

    =IF('Story Events'!D1<1,INDEX('Story Event Lookup'!$C$2:$C$300,MATCH('Story Events'!$E$2,'Story Event Lookup'!$B$2:$B$300,0)),INDEX('Story Event Lookup'!$C$2:$C$300,MATCH('Story Events'!$D$1,'Story Event Lookup'!$A$2:$A$300,0)))

    *I feel like an idiot*
    The problem was D1 I didn't have $D$1 and the value was changing when I typed the number in D1 to a different cell so it was always evaluating as false.

    Thanks for the help. Such a stupid error.

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,099

    Re: What am I doing wrong in this if statement?

    You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

+ 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. [SOLVED] Something wrong with the IF statement
    By billj in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-04-2016, 09:58 AM
  2. What's wrong with this IF statement?
    By djarcadian in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-14-2013, 04:33 PM
  3. What's wrong with this =if and =and and =or statement
    By soysoy05 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-05-2011, 02:57 AM
  4. wrong:IF statement
    By scubadiver007 in forum Excel General
    Replies: 2
    Last Post: 03-28-2011, 11:47 AM
  5. If Statement, or am I going about this wrong?
    By JJAndradeIII in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-11-2008, 06:49 AM
  6. What is wrong with this If statement?
    By shaolin in forum Excel General
    Replies: 3
    Last Post: 01-30-2008, 01:11 PM
  7. [SOLVED] wts wrong with this statement
    By Jason in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-24-2006, 10:30 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