Closed Thread
Results 1 to 18 of 18

How to extract data if a value is present

  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":
    Please Login or Register  to view this content.
    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!)

    Please Login or Register  to view this content.
    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.

    Please Login or Register  to view this content.
    I hope that helps.

  7. #7
    Registered User
    Join Date
    03-21-2008
    Posts
    52
    Hmmm, getting a value error now. Maybe we should look at fixing the n/a error. The formula that is creating the errors (because it is refering to data that is not yet present) is:

    Please Login or Register  to view this content.
    Do we use ISERROR to get rid of the errors? I'll try a few things but any help would be appreciated!

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

    Trapping potential #NA errors in formulas

    Try something like this:
    Please Login or Register  to view this content.
    Can you work with that?

  9. #9
    Registered User
    Join Date
    03-21-2008
    Posts
    52
    So I've sorted the n/a error in my original calculations by changing it to:

    Please Login or Register  to view this content.
    I'm still getting the value error. Any suggestions please Ron/anyone?

    Thanks, Chris

  10. #10
    Registered User
    Join Date
    03-21-2008
    Posts
    52
    Thanks Ron - we got there at about the same time on the n/a error!

    I don't know where to begin with the value error though, as I don't understand your original formula completely.

    Have I done something wrong when inputting my own cell range?

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

    Trapping potential #NA errors in formulas

    Technically, the formulas that you and I posted would trap
    the #NA (no matching value) error. Now it's time to look in Col_Q of the
    referenced range to see if any of those cells resolve to "#VALUE!".

  12. #12
    Registered User
    Join Date
    03-21-2008
    Posts
    52
    Aha! The cells that this formula is being run over will sometimes contain just a letter (N, S, L etc.). If I run it just on cells with numeric or alpha-numeric containing the H it's fine. So how do we get it to ignore cells that contain just a letter?

    Thanks for helping me with this Ron!

    Oh yeah, they may also contain 2 letters eg. SU. Thanks!
    Last edited by monkdelafunk; 08-28-2008 at 01:42 PM. Reason: Forgot to mention!

  13. #13
    Registered User
    Join Date
    03-21-2008
    Posts
    52
    Scratch that Ron, it only works on cells that contain alpha numeric data, not just alpha or numeric

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

    Trapping potential errors in formulas

    Try this ARRAY FORMULA:
    Please Login or Register  to view this content.
    Does that work?

  15. #15
    Registered User
    Join Date
    03-21-2008
    Posts
    52
    That returns 0, I'm testing it now just on 4 cells that contain:

    H, 3.75
    9
    H, 1
    N

  16. #16
    Registered User
    Join Date
    03-21-2008
    Posts
    52
    Forgot to press shift+Ctrl+enter! Works a treat!

  17. #17
    Registered User
    Join Date
    03-21-2008
    Posts
    52
    Nice work Ron! I'm going to be really annoying now...

    Is it possible to use VLOOKUP to take a name from column A, search for it in another sheet and perform this formula just across that row? Sorry!!

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

    New question....New thread

    Quote Originally Posted by monkdelafunk View Post
    Nice work Ron! I'm going to be really annoying now...

    Is it possible to use VLOOKUP to take a name from column A, search for it in another sheet and perform this formula just across that row? Sorry!!
    ...and I'm going to enforce the forum rules!

    Please post the new question in a new thread.

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