+ Reply to Thread
Results 1 to 6 of 6

Extract and Sum Numerical Values using string matching from single/multi value cell

  1. #1
    Registered User
    Join Date
    12-14-2020
    Location
    Puslinch Ontario
    MS-Off Ver
    365
    Posts
    18

    Extract and Sum Numerical Values using string matching from single/multi value cell

    I'm trying to create a schedule and want to be able to show both (Workers x days) but also an overview of each project and what actions are occuring on what day. I need to be able to sum all allocated time to have knowledge of total time alloted.

    Basically, I have "Action"_"hours" with a possibility of "Action_A_hours, Action B_Hours, Action C_Hours, Action D_Hours" and I want to extract any match of "Action X" and sum all hours that match.

    I've been working on this overall for over 20 hours and think I need a change of perspective.


    From the attachment:
    I want to take the data in the Monday column, and where the string matches in the project overview column "2675_Mechanism Drive_Guard Bottom_Fit" I want to sum all numbers that match from the Monday column. The result i'm looking for is highlighted in yellow.

    The difficulty for me right now is that some of the cells in the Monday column can be multi tasked, with the comma delimiter as shown in G3.
    Attached Files Attached Files

  2. #2
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Extract and Sum Numerical Values using string matching from single/multi value cell

    there will be better, more elegant approaches using some of the new O365 functions but

    D17
    =SUMPRODUCT(--TEXT(MID(SUBSTITUTE(SUBSTITUTE($G$2:$G$4,$B$14&"_"&$B$15&"_"&$B$16&"_"&D$15&"_",""),",",REPT(" ",100)),1+100*(COLUMN($A:$D)-1),100),"#;-#;0;\0"))
    copied to E17

    would return 11 and 4, respectively.

    edit: just to add, relative to subsequent post, the above was designed to cater for possibility of multiple entries on same line for same type of work, if this isn't a possibility then it can be simplified.
    Last edited by XLent; 12-15-2020 at 12:07 PM.

  3. #3
    Registered User
    Join Date
    12-03-2020
    Location
    Bangkok,Thailand
    MS-Off Ver
    365
    Posts
    29

    Re: Extract and Sum Numerical Values using string matching from single/multi value cell

    Try this

    D17:
    =SUM(IFERROR(--MID($G$2:$G$4,FIND(C17,$G$2:$G$4)+LEN(C17)+1,2),0))
    E18
    =SUM(IFERROR(--MID($G$2:$G$4,FIND(C18,$G$2:$G$4)+LEN(C18)+1,2),0))
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    12-14-2020
    Location
    Puslinch Ontario
    MS-Off Ver
    365
    Posts
    18

    Re: Extract and Sum Numerical Values using string matching from single/multi value cell

    KokiKoki,

    Thank you very much. I must've been very close. I had tried something similar to return the workers who matched and I did this through a search and textjoin. The search gave me the array of {1,44,1}
    positioning. I figured I could use something similar with mid but couldn't get mid to work in array format and had a little issue finding relevant stuff online.

    I guess my error had come when trying to us the string return from search which gave me a 'string array' of {1,44,1}, and I wanted to use those numbers in the mid array formula.

    so I had tried:

    {MID = (G2:G4, G32, 2)}
    where G32 was technically string of 1,44,1.

    When I ran that I got #value, and looking at the formula it only showed my G2:G4 as returning G2, which led me down the road of thinking I couldn't use mid in an array or that the string entry didn't work.

    Running through it now I see where the error was, I had to use Find(C17, $G$2:$G$4) to get my array of {1,44,1}, but even then the function doesn't work without the '--' prior to the mid.

    What does '--Mid()' do that allowed the array to work rather than just Mid()? I see the --Mid in both replies.

  5. #5
    Registered User
    Join Date
    12-14-2020
    Location
    Puslinch Ontario
    MS-Off Ver
    365
    Posts
    18

    Re: Extract and Sum Numerical Values using string matching from single/multi value cell

    Think I found the proper way to reply,

    In short, What does '--Mid()' do that allowed the array to work rather than just Mid()? I see the --Mid in both replies.

  6. #6
    Registered User
    Join Date
    12-03-2020
    Location
    Bangkok,Thailand
    MS-Off Ver
    365
    Posts
    29

    Re: Extract and Sum Numerical Values using string matching from single/multi value cell

    Hi, Tbenz,

    Mid() returns texts, which are, in this case, "02" "05" "04". To make these texts to numbers, just put "--" before mid(). Then, you can do whatever you want with the number array.
    Last edited by AliGW; 12-15-2020 at 01:08 PM. Reason: PLEASE don't quote unnecessarily!

+ 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. Extract multiple text values from a single multi-line cell
    By charliechaz in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-31-2019, 10:36 AM
  2. [SOLVED] extract multi-letter string bits from string depending on size and case
    By luv2glyd in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-18-2017, 10:41 PM
  3. Multiple Numerical Values in a Single Cell
    By Olgethorpe in forum Excel General
    Replies: 3
    Last Post: 01-31-2016, 07:55 PM
  4. Replies: 11
    Last Post: 06-27-2014, 08:11 AM
  5. Macro to extract a certain string from a single cell
    By karthik013 in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 11-26-2012, 12:03 PM
  6. Replies: 7
    Last Post: 03-29-2012, 01:25 PM
  7. Extract one numerical value from single cell with multiple values?
    By cszy67 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-26-2005, 09:49 PM

Tags for this Thread

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