+ Reply to Thread
Results 1 to 13 of 13

Formula to identify Segments of text and percentages

  1. #1
    Registered User
    Join Date
    04-20-2021
    Location
    Pretoria, South Africa
    MS-Off Ver
    Office 365
    Posts
    7

    Formula to identify Segments of text and percentages

    Hi,

    Having trouble creating the right formula or VBA code to pull out the desired details from coloumn A in the example to look like coloumn B

    I need to retrieve the function with the highest percentage as the dominant function in the string of text with the criteria being the highest percentage. I am not sure if there is a formula I can use or alternatively a VBA code. I hope I have articulated my problem well.

    Please see the example sheet showing the desired outcome.

    thank you
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,169

    Re: Formula to identify Segments of text and percentages

    Please Login or Register  to view this content.
    in B2

    =MaxPerc(A2)

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,001

    Re: Formula to identify Segments of text and percentages

    Here's a formula alternative:

    =FILTERXML("<A><B>"&SUBSTITUTE(A2,";","</B><B>")&"</B></A>","//B[contains(.,'"&MAX(IF(ISERROR(1*MID(A2,ROW($1:$1000),3)),0,1*MID(A2,ROW($1:$1000),3)))&"')]")
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  4. #4
    Registered User
    Join Date
    04-20-2021
    Location
    Pretoria, South Africa
    MS-Off Ver
    Office 365
    Posts
    7

    Re: Formula to identify Segments of text and percentages

    Hey Glenn, thanks for the formula - any reason why it may be giving me an error code? VALUE!

  5. #5
    Registered User
    Join Date
    04-20-2021
    Location
    Pretoria, South Africa
    MS-Off Ver
    Office 365
    Posts
    7

    Re: Formula to identify Segments of text and percentages

    Hi Glenn, realised why it returns a #VALUE! error - only happens when there is a single entry into the info cell
    Attached Files Attached Files

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,001

    Re: Formula to identify Segments of text and percentages

    Umm. No. It works perfectly for that single example.
    Attached Files Attached Files

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,001

    Re: Formula to identify Segments of text and percentages

    Are there any values that contain either

    &
    or
    < ??

  8. #8
    Registered User
    Join Date
    04-20-2021
    Location
    Pretoria, South Africa
    MS-Off Ver
    Office 365
    Posts
    7

    Re: Formula to identify Segments of text and percentages

    Thanks John

  9. #9
    Registered User
    Join Date
    04-20-2021
    Location
    Pretoria, South Africa
    MS-Off Ver
    Office 365
    Posts
    7

    Re: Formula to identify Segments of text and percentages

    yes there is a & would this be causing the error?

  10. #10
    Registered User
    Join Date
    04-20-2021
    Location
    Pretoria, South Africa
    MS-Off Ver
    Office 365
    Posts
    7

    Re: Formula to identify Segments of text and percentages

    got it working! Thanks!

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,001

    Re: Formula to identify Segments of text and percentages

    Quote Originally Posted by BrianJS View Post
    got it working! Thanks!
    Who are you talking to here?

  12. #12
    Registered User
    Join Date
    04-20-2021
    Location
    Pretoria, South Africa
    MS-Off Ver
    Office 365
    Posts
    7

    Re: Formula to identify Segments of text and percentages

    My apologies, Glenn - After you mentioned the & sign I went and had a look and this solved my problem, thank you!

  13. #13
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,001

    Re: Formula to identify Segments of text and percentages

    It can be built into the formula too. It's a BIT more complicated than normal in your case as I am using the ; as the delimiter to build up the XML string... However, this will safely allow the presence of & in your strings:

    =FILTERXML("<A><B>"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,";","¦"),"&","#38;"),"¦","</B><B>")&"</B></A>","//B[contains(.,'"&MAX(IF(ISERROR(1*MID(A2,ROW($1:$1000),3)),0,1*MID(A2,ROW($1:$1000),3)))&"')]")

    You're welcome.



    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

    Finally, if that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.
    Attached Files Attached Files

+ 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] Identify 1 IP address from a cell with multiple IPs match against legend of IP segments
    By suchetherrah in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-27-2018, 11:52 AM
  2. [SOLVED] Split percentages into groups of 10 for 5 segments
    By dchubbock in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-11-2014, 06:56 PM
  3. Defining Segments of Text From General Workbook
    By smiz in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-27-2013, 09:57 AM
  4. [SOLVED] TEXT Formula to identify rows of cells with Matching TEXT *** Actual Worksheet attached.
    By steve08087 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-29-2013, 12:42 PM
  5. [SOLVED] Formula to identify text within a cell
    By Glayva in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-22-2012, 05:29 AM
  6. Identify percentages
    By NoCanDo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-27-2008, 03:34 AM
  7. How do I take segments (Example, $1 $2 $3) from a text box (or string)???
    By BaLLZaCH in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2008, 08:31 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