+ Reply to Thread
Results 1 to 6 of 6

Subtracting Extracted numbers from a string

  1. #1
    Forum Contributor
    Join Date
    11-22-2020
    Location
    Sydney Australia
    MS-Off Ver
    365
    Posts
    202

    Subtracting Extracted numbers from a string

    Hi All,

    I have a situation where I would like to subtract the number of occurrences that the count of numbers that meets a condition can be subtracted from the starting number.

    What does this mean?

    I have a starting number of 4.
    I have a string that contains 1,2,3
    The criteria is to subtract the count of numbers < 4.
    In this case, the count of numbers < 4 is 3, therefore 4 - 3 =1 is the result.

    Or

    I have a starting number of 4.
    I have a string that contains 3,7,8
    The criteria is to subtract the count of numbers < 4.
    In this case, the count of numbers < 4 is 1, therefore 4 -1 = 3 is the result.

    Or

    I have a starting number of 4.
    I have a string that contains 7,9,10,11
    The criteria is to subtract the count of numbers < 4
    In this case, the count of numbers , 4 is 0, therefore 4 -0 = 4 is the result.

    I have no idea where to start.

    I have attached a workbook with this example in it.

    Ideally I would like this to be an excel cell formula, not a vba macro.

    Any guidance is most appreciated.

    Thanks

    Jeff.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,294

    Re: Subtracting Extracted numbers from a string

    I suggest this option
    Attached Files Attached Files

  3. #3
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Subtracting Extracted numbers from a string

    Please try
    for 3 string number
    =A4+SUM(-(--MID(B4,SEQUENCE(3,,,2),1)<A4))

    or any string number
    =A4+SUM(-(FILTERXML("<x><m>"&SUBSTITUTE(B4,",","</m><m>")&"</m></x>","//m")<A4))
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,084

    Re: Subtracting Extracted numbers from a string

    Another option similar to Bo_Ry's
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    11-22-2020
    Location
    Sydney Australia
    MS-Off Ver
    365
    Posts
    202

    Re: Subtracting Extracted numbers from a string

    Thank you all.

    I am in total Awe of the knowledge of the people in this forum.

    I am proud to work with you all.

    Jeff.

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,084

    Re: Subtracting Extracted numbers from a string

    Glad to help & thanks for the feedback

+ 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. [SOLVED] Numbers with percentage to be extracted from text
    By ImranBhatti in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 11-28-2019, 04:04 PM
  2. [SOLVED] Type mismatch for date extracted from string
    By caabdul in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-03-2018, 09:51 AM
  3. Replies: 18
    Last Post: 10-26-2015, 01:35 AM
  4. Excel 2007 : Numbers to be extracted
    By sushil10s in forum Excel General
    Replies: 5
    Last Post: 08-20-2015, 09:07 AM
  5. Extract a String from the Pdf along with the Page no of the extracted Value
    By kumark in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-26-2015, 07:47 AM
  6. [SOLVED] SUMIF Query: How to summarise values based on data extracted from a text string
    By The_Snook in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 07-17-2013, 10:12 AM
  7. [SOLVED] Subtracting One String from Another
    By EzRouter in forum Excel General
    Replies: 5
    Last Post: 04-03-2012, 10:03 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