+ Reply to Thread
Results 1 to 5 of 5

Ignoring blank cells in an IF statement formula

  1. #1
    Registered User
    Join Date
    06-26-2008
    Location
    Rock Hill
    Posts
    41

    Ignoring blank cells in an IF statement formula

    I am trying to ignore blank cells in a certain column. Columns A and B contain data. Column A contains number between 2 and 11, and column B contains measured data.
    The formula I am using is as follows:

    {=VAR(AVERAGE(IF(A1:A100=2,B1:B100,"")),......}

    This formula goes on using 2 to 11 in the logic test statement and takes the variance. But, if one of the cells is blank in the B column, an error occurs in the IF statement evaluation, leading to an error as the final answer.
    This workbook will be used by others, and there is no way to predetermine which cells will be blank when data is pasted into the worksheet.

    Thanks.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    i cant get that bit to fail

    {=AVERAGE(IF(A1:A100=2,B1:B100,""))}
    filled b up with various numbers
    and formula calculated the average of every value in b corresponding to 2 in col a
    irrespective if col b had blanks either anywhere or in the same row as a 2 in a
    but you do get a #div/0 error if no 2 present in col a

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    If you mean that you don't want blanks in column B included in the average as if they're zeroes then try

    =AVERAGE(IF(A1:A100=2,IF(B1:B100<>"",B1:B100)))

  4. #4
    Registered User
    Join Date
    06-26-2008
    Location
    Rock Hill
    Posts
    41
    Thanks for all your help. I did not want the blanks in column B included in the averages, as that would have thrown off the data. When I put in the final formula, I used the offset function and combined it with the count function since the amount of data will vary. I got an error saying that "The formula is too long" before I got done entering it. How long can a formula be? The data are in columns O and Q (used A and B as an expample). There has got to be an easier way to do this. It escapes me currently. See below.

    {=VAR(AVERAGE(IF(OFFSET('2320 Data'!$O$3,0,0,COUNTA('2320 Data'!$O$3:$O$65536),1)=2,IF(OFFSET('2320 Data'!$Q$3,0,0,COUNTA('2320 Data'!$Q$3:$Q$65536),1)<>0,OFFSET('2320 Data'!$Q$3,0,0,COUNTA('2320 Data'!$Q$3:$Q$65536),1),""))),AVERAGE(IF(OFFSET('2320 Data'!$O$3,0,0,COUNTA('2320 Data'!$O$3:$O$65536),1)=3,IF(OFFSET('2320 Data'!$Q$3,0,0,COUNTA('2320 Data'!$Q$3:$Q$65536),1)<>0,OFFSET('2320 Data'!$Q$3,0,0,COUNTA('2320 Data'!$Q$3:$Q$65536),1),""))),AVERAGE(IF(OFFSET('2320 Data'!$O$3,0,0,COUNTA('2320 Data'!$O$3:$O$65536),1)=4,IF(OFFSET('2320 Data'!$Q$3,0,0,COUNTA('2320 Data'!$Q$3:$Q$65536),1)<>0,OFFSET('2320 Data'!$Q$3,0,0,COUNTA('2320 Data'!$Q$3:$Q$65536),1),""))),AVERAGE(IF(OFFSET('2320 Data'!$O$3,0,0,COUNTA('2320 Data'!$O$3:$O$65536),1)=5,IF(OFFSET('2320 Data'!$Q$3,0,0,COUNTA('2320 Data'!$Q$3:$Q$65536),1)<>0,OFFSET('2320 Data'!$Q$3,0,0,COUNTA('2320 Data'!$Q$3:$Q$65536),1),""))))}

  5. #5
    Registered User
    Join Date
    06-26-2008
    Location
    Rock Hill
    Posts
    41
    I found a way to make it shorter. Thanks. It works now. But if anyone knows the upper limit to the size of a formula, I would be very interested in knowing that information.
    Last edited by Macro-wave; 08-26-2008 at 10:22 AM. Reason: forgot something

+ 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. array formula: How to aggegrate data, removing blank cells?
    By tim594 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 03-05-2013, 02:37 PM
  2. Repeat data in blank cells
    By mackey in forum Excel General
    Replies: 2
    Last Post: 02-06-2008, 09:18 AM
  3. writing a formula to return non-empty cells
    By pmetzak in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-18-2007, 03:34 PM
  4. [SOLVED] Placing a formula into merged cells!!!
    By ghostly1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-27-2007, 10:55 AM
  5. Highlight formula results that have a blank value
    By alexwren in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-18-2007, 05:47 PM

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