Closed Thread
Results 1 to 18 of 18

How to extract data if a value is present

Hybrid View

  1. #1
    Registered User
    Join Date
    03-21-2008
    Posts
    52

    How to extract data if a value is present

    My brain isn't working today!

    I know how to use COUNTIF to count up the number of times something appears. What I want to do is add up values if an H is present in the cell with the value eg. if 3 cells contained:

    H, 3.5
    7.5
    H, 3

    ...then 6.5 would be returned.

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Conditionally sum numeric portion of alpha-numeric text

    With
    A1: H, 3.5
    A2: 7.5
    A3: H, 3

    This formula sums the numeric sections of cells prefixed with "H":
    B1: =SUMPRODUCT((LEFT(A1:A3,1)="H")*MID(A1:A3,3,255))
    In the above example, the formula returns: 6.5

    Is that something you can work with?
    Last edited by Ron Coderre; 08-28-2008 at 10:44 AM. Reason: Edited to correct sample result from 7.5 to 6.5
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    03-21-2008
    Posts
    52
    Thanks for the prompt response Ron.

    I've applied the cells I need to use to this formula but it is returning as n/a.

    My formula looks like this (and I've probably done something wrong!)

    =SUMPRODUCT((LEFT(P8:BX182,1)="H")*MID(P8:BX182,3,255))
    Thanks for your help

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Troubleshooting

    Start by checking your data. If P8:BX182 contain formulas, do any of them return #NA?

  5. #5
    Registered User
    Join Date
    03-21-2008
    Posts
    52
    Yeah, tons of them! Is there a way of ignoring these results as otherwise the cells I'm going to be searching will make my formula huge!

  6. #6
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Dealing with #NA errors in a referenced range

    It's more professional to fix the formulas so they don't return #NA.

    But, if you must have the errors, here are two ARRAY FORMULA options.
    Note: Commit array formulas with CTRL+SHIFT+ENTER, instead of just ENTER.

    Option_1:
    =SUMPRODUCT(IF(ISTEXT(P8:BX182),(LEFT(P8:BX182,1)="H")*MID(P8:BX182,3,255)))
    
    Option_2:
    =SUMPRODUCT(IF(NOT(ISERROR(P8:BX182)),(LEFT(P8:BX182,1)="H")*MID(P8:BX182,3,255)))
    I hope that helps.

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Can't seem to get the automatic selection of data present down!
    By wantucce in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 08-18-2008, 04:51 AM
  2. Data Extract
    By joeserrone in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-06-2008, 11:34 PM
  3. Chart to only reflect points where data present?
    By mhb22079 in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 12-04-2007, 01:12 PM
  4. insert rows only if data is present
    By jbenton in forum Excel General
    Replies: 0
    Last Post: 11-08-2007, 12:43 PM
  5. Replies: 3
    Last Post: 05-12-2007, 08:12 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