+ Reply to Thread
Results 1 to 8 of 8

Looking at an IF function that will return the highlighted numbers

Hybrid View

  1. #1
    Registered User
    Join Date
    03-23-2015
    Location
    toronto
    MS-Off Ver
    2010
    Posts
    52

    Looking at an IF function that will return the highlighted numbers

    Best thought is an iF statement that if unit price is 1 it will be a 6 character/digit that starts with the AB followed by unit price. Thanks!
    Last edited by itshere; 04-25-2022 at 12:55 PM.

  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
    30,751

    Re: Looking at an IF function that will return the highlighted numbers

    Try

    =MID(B2,FIND("AB",B2,1),6)

    text in B2
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Registered User
    Join Date
    03-23-2015
    Location
    toronto
    MS-Off Ver
    2010
    Posts
    52

    Re: Looking at an IF function that will return the highlighted numbers

    is there an IF statement that can be derived from this?

  4. #4
    Registered User
    Join Date
    03-23-2015
    Location
    toronto
    MS-Off Ver
    2010
    Posts
    52

    Re: Looking at an IF function that will return the highlighted numbers

    issues with that because the second line already has AB12 so it uses that instead of the AB2000

  5. #5
    Registered User
    Join Date
    03-23-2015
    Location
    toronto
    MS-Off Ver
    2010
    Posts
    52

    Re: Looking at an IF function that will return the highlighted numbers

    Quote Originally Posted by JohnTopley View Post
    Try

    =MID(B2,FIND("AB",B2,1),6)

    text in B2
    issues with that because the second line already has AB12 so it uses that instead of the AB2000

  6. #6
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,879

    Re: Looking at an IF function that will return the highlighted numbers

    Try the following:
    Formula: copy to clipboard
    =MID(SUBSTITUTE(B2,"AB","/",(LEN(B2)-LEN(SUBSTITUTE(B2,"AB","")))/2),SEARCH("/",SUBSTITUTE(B2,"AB","/",(LEN(B2)-LEN(SUBSTITUTE(B2,"AB","")))/2))+1,1)

    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  7. #7
    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
    30,751

    Re: Looking at an IF function that will return the highlighted numbers

    Function findAB(r As Range) As String
    Dim t() As String
    xstr = r
    t = Split(xstr, " ")
    For i = 0 To UBound(t)
        x = Trim(t(i))
        If Left(x, 2) = "AB" And Len(x) = 6 And IsNumeric(Mid(x, 3, 4)) Then
            findAB = x
            Exit Function
        End If
    Next i
    findAB = ""
    End Function
    =findAB(B2)

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

    Re: Looking at an IF function that will return the highlighted numbers

    Next time... please read the yellow banner (top) and attach an Excel sheet to work with... not a picture of one.


    =FILTERXML("<A><B>"&SUBSTITUTE(A2," ","</B><B>")&"</B></A>","//B[starts-with(., 'AB') and string-length()=6]")
    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

+ 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. Replies: 7
    Last Post: 11-14-2020, 02:35 PM
  2. Using the Split function to return column numbers
    By mitchbvi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-16-2019, 05:06 PM
  3. Replies: 5
    Last Post: 04-04-2018, 12:47 AM
  4. Delete Highlighted Numbers or Not highlighted Numbers
    By Jerry HKA in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-08-2014, 11:19 AM
  5. Return Total Count of highlighted Cells
    By Cansa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2013, 12:54 PM
  6. how do I return a HIGHLIGHTED (not selected) item from a ListBox?
    By michaeljoeyeager in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-27-2012, 08:27 AM
  7. Function that will only return cells with text or numbers
    By indyjojo in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-14-2010, 04:12 PM

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