+ Reply to Thread
Results 1 to 8 of 8

IF statements and getting excel to skip rows and leave no blanks or falses

  1. #1
    Registered User
    Join Date
    12-19-2012
    Location
    austin
    MS-Off Ver
    Excel 2010
    Posts
    3

    IF statements and getting excel to skip rows and leave no blanks or falses

    I have two spead sheets one named "2nd" and one named "sheet 1". on the first sheet which is named 2nd I have a list of names in column A and in column C I have a letter: "D"= which mean day shift "E"= mean evenign shift and "N"= which means night shift. on the second sheet" sheet 1" I would like it to read column C in speed sheet "2nd" and if column C has a "D" I would like it to push out the name that is in column A in speed "2nd". Now I here is the formula that I am using to do that: = IF('2nd'!C:C= "D", '2nd'!A:A) This forumla is doing what I want it to do but every time it reads a column that does not have a "D" it continues to push out the word "False". I would like it to skip to the next row and continue reading the rows until it finds a nother "D". I do not want any blank row in "sheet 1" how do I do this. I have attached my excel document so that you can understand what I am saying.


    Thanks for your help,
    Chanelle
    Attached Files Attached Files
    Last edited by JBeaucaire; 12-31-2012 at 03:30 PM. Reason: Corrected thread title to topic only, as per forum rules

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: IF statements and getting excel to skip rows and leave no blanks or falses

    This is an array formula. You'll need to adapt the "ranges" within the formula if you increase the number of rows on the "2nd" sheet. Do not try to use them with whole columns. In Sheet1 cell B10 put this array formula:

    =IF(ROW(A1)>COUNTIF('2nd'!$C$1:$C$11, "D"), "", INDEX('2nd'!$A$1:$A$11,SMALL(IF('2nd'!$C$1:$C$11="D",ROW('2nd'!$C$1:$C$11),""),ROW(A1))))

    ...and confirm the formula by pressing CTRL-SHIFT-ENTER to activate the array. When the first name appears, you can copy that cell dpwn through B20.

    The reference "A1" marked in RED in that formula is a trick to pull the FIRST value that has a "D", so when you copy that formula into B21 to start the next group, you will need to make sure that is set back to A1 and the "D" is changed to "E" or "N" or whatever group you are collecting.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    12-19-2012
    Location
    austin
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: IF statements and getting excel to skip rows and leave no blanks or falses

    OMG. I dont know why this is not working. In cell b10 in sheet 1 instead of the name is has #value! i attached the sheet again...
    Attached Files Attached Files

  4. #4
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: IF statements and getting excel to skip rows and leave no blanks or falses

    Quote Originally Posted by cmwalton View Post
    OMG. I dont know why this is not working. In cell b10 in sheet 1 instead of the name is has #value! i attached the sheet again...
    It's an array formula. You have to use Ctrl+Shift+Enter, not just Enter

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: IF statements and getting excel to skip rows and leave no blanks or falses

    In your file on Sheet1 enter this array formula** in B10 and copy down until you get blanks:

    =IFERROR(INDEX('2nd'!A:A,SMALL(IF('2nd'!C$1:C$11="D",ROW('2nd'!C$1:C$11)),ROWS(B$10:B10))),"")

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: IF statements and getting excel to skip rows and leave no blanks or falses

    this, longer, non-array formula in Sheet1!B10 will produce the same result:

    Please Login or Register  to view this content.
    if you were to capture D or E or P in another cell, such as Sheet1!B9, then the formula could be (formula is not case-sensitive):

    Please Login or Register  to view this content.
    Last edited by icestationzbra; 12-31-2012 at 07:10 PM.
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

  7. #7
    Registered User
    Join Date
    12-19-2012
    Location
    austin
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: IF statements and getting excel to skip rows and leave no blanks or falses

    Thamks you guys that worked great. I used =IFERROR(INDEX('2nd'!A:A,SMALL(IF('2nd'!C$1:C$11="D",ROW('2nd'!C$1:C$11)),ROWS(B$10:B10))),"") one more question now I need the formula to read a "D" or and "A" Im confused where to put the or statement...

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: IF statements and getting excel to skip rows and leave no blanks or falses

    Oe way...

    =IFERROR(INDEX('2nd'!A:A,SMALL(IF('2nd'!C$1:C$11={"D","A"},ROW('2nd'!C$1:C$11)),ROWS(B$10:B15))),"")

    Still array entered!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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