+ Reply to Thread
Results 1 to 12 of 12

searching a cell for a 7 digit number - please help

  1. #1
    Registered User
    Join Date
    08-02-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    6

    searching a cell for a 7 digit number - please help

    Good morning all,

    wondering if you could possibly help. I'm trying to search a column that has cells with various length strings. Included in the strange (at random locations) could be possibly be a 7 digit number starting with 4. I want a formula that counts the number of cells with contain that 7 digit number. Is this possible?

    Thanks in advance for your help.

    Jamil

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: searching a cell for a 7 digit number - please help

    Hi

    Assuming that your data start in A2, in B2 and copy down use this formula. This will be a helper and hidden column.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Then use

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    to get your result.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: searching a cell for a 7 digit number - please help

    or you could use like =SUMPRODUCT(--(LEN(A:A)=7)*(LEFT(A:A,1)="4")) assuming your data starts in column A
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    WANT TO SAY THANKS, HIT ADD REPUTATION (*) AT THE BOTTOM LEFT CORNER OF THE POST

    More we learn about excel, more it shows us, how less we know about it.

    for chemistry
    https://www.youtube.com/c/chemistrybyshivaansh

  4. #4
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: searching a cell for a 7 digit number - please help

    Here is my solution.

    A1 = first text string: A2 is second, A3 is third, etc.

    B1 = LEFT( RIGHT(A1, LEN(A1) - FIND("4", A1) +1), 7)
    Works by:
    1) Find the position of the first instance of the number "4" in the string,
    2) clipping off everything to the left of that position,
    3) clipping off seven digits rightward of the left-clipped value

    C1 = IF(B1 > 1000000, 1, 0)

    Drag B1 and C1 down.

    D1 = SUM(C:C)

    (I would have used a COUNTIF in C1 instead of another helper column but I see that you are using Excel 2003?)

    Then D1 will give you the number of text strings that contain a 7-digit number that start with "4".

    Caveats:
    1) If the number doesn't start with 4, this formula won't return it.
    2) Something like abc4def4123456
    will return
    4def412 (text, not a number)
    not
    4123456 (the 7-digit number)

    EDIT:
    Aaaand I double-guessed myself and it turns out that excel 2003 had COUNTIF after all, huh?
    Last edited by ben_hensel; 10-14-2013 at 06:12 AM.

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,762

    Re: searching a cell for a 7 digit number - please help

    Quote Originally Posted by zakajam1980 View Post
    I'm trying to search a column that has cells with various length strings. Included in the strange (at random locations) could be possibly be a 7 digit number starting with 4. I want a formula that counts the number of cells with contain that 7 digit number.
    I'm assuming that your strings could look something like this:

    "xxyy abc 4444455 adf sgh"

    Will the 7 digit number be the only number in the string? Could there be 6 or 8 digit numbers that you don't want to count - I assume that the 7 digit numbers can be different numbers in different cells, is that the case?

    Perhaps you could supply a small sample of the data (5 to 10 rows)?
    Audere est facere

  6. #6
    Registered User
    Join Date
    08-02-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: searching a cell for a 7 digit number - please help

    Thanks for your replies so far. The sample could contain any random text as it is part of conversation download. Yes you are right the 7 digit number could be completely random but will always start with a four. I've included a sample sample.

    Again really appreciate all your help.
    Attached Files Attached Files

  7. #7
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,762

    Re: searching a cell for a 7 digit number - please help

    If you use this "array formula" in C2

    =COUNT(IF(MID(B2,ROW(INDIRECT("1:"&LEN(B2)-6)),1)="4",MID(B2,ROW(INDIRECT("1:"&LEN(B2)-6)),7)+0))>0

    confirmed with CTRL+SHIFT+ENTER

    that will give you TRUE if B2 contains a 7 digit number beginning with 4

  8. #8
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: searching a cell for a 7 digit number - please help

    Try This array formula in C2 (Copy paste Below Formula, Hold control and shift then hit enter to confirm it as an array)
    =MID(B2,MATCH(TRUE,ISNUMBER(TRIM(MID(B2,ISNUMBER(SEARCH(" ",MID(B2,ROW(INDIRECT("1:"&LEN(B2))),1)))*ROW(INDIRECT("1:"&LEN(B2))),8))+0),0),8)+0
    Then Drag down this will extract the numbers in the formula.

    Now in D2 Enter below array formula
    =SUM(IFERROR(LEN(C2:C11)=7,0)*IFERROR(LEFT(C2:C11)+0=4,0))
    This will give you the count based on 7 characters and 4 in the start

  9. #9
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: searching a cell for a 7 digit number - please help

    Find the attached.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    08-02-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: searching a cell for a 7 digit number - please help

    Guys thanks for your responses, I used the last one and appeared to work well.

    Much appreciated!

  11. #11
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,762

    Re: searching a cell for a 7 digit number - please help

    Don't you need to count B6 which does contain a 7 digit number beginning with 4.....or doesn't that count?

  12. #12
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: searching a cell for a 7 digit number - please help

    Quote Originally Posted by daddylonglegs View Post
    Don't you need to count B6 which does contain a 7 digit number beginning with 4.....or doesn't that count?
    Dear Sir, Good point to bring in notice I have Taken spaces into consideration, How below will be
    zakajam1980 try this in B2
    =MID(B2,MATCH(TRUE,ISNUMBER(MID(B2,ISNUMBER(MID(B2,ROW(INDIRECT("1:"&LEN(B2))),1)+0)*ROW(INDIRECT("1:"&LEN(B2))),7)+0),0),7)+0
    confirm with control shift and ENter

+ 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] Color a single digit in a mult-digit number cell
    By Phyllis in forum Excel General
    Replies: 8
    Last Post: 09-30-2022, 04:22 PM
  2. [SOLVED] Formatting to make 2 digit number show up at 3 digit number.
    By cadamhill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-18-2012, 06:58 PM
  3. [SOLVED] how to identify only 2 digit permuted number from list of 3 digit number
    By bigcrap in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 09-08-2011, 03:06 PM
  4. searching for a number with 1 digit
    By mkozakov in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2010, 01:51 PM
  5. Searching for a 4 digit number within multiple sheets
    By corty_d in forum Excel General
    Replies: 5
    Last Post: 11-04-2008, 09:31 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