+ Reply to Thread
Results 1 to 8 of 8

Counting and substituting

  1. #1
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Counting and substituting

    Hi,

    I am working on a database where the lookup requires numbers to be in a set format and set number of charters.

    The first letter will either be E, O or I and then it will be followed by a “.” and then 6 digits. E.g. E.000123

    However the data I am using isn’t always in the correct format. What I need is a formula that will count the number of numbers between the two “.” And then add zeros after the first dot to ensure there are 6 numbers.

    e.g. E.123 would become E.000123

    I have attached an example

    Can anyone help with the formula?

    Regards

    Paul
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373

    Re: Counting and substituting

    H Paul

    Try in F4:

    =LEFT(D4,2)&TEXT(MID(D4,3,FIND(".",D4,3)-3),"000000")

  3. #3
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Counting and substituting

    Try

    =LEFT(D4,2)&TEXT(MID(SUBSTITUTE(D4,".",REPT(" ",255),2),3,255),"000000")
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Counting and substituting

    try
    =LEFT(D4,2)&TEXT(MID(SUBSTITUTE(D4,".",REPT(" ",10),2),3,6),"000000")
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Counting and substituting

    Thanks all for the fomrulas!

    I apologise my requirement has already changed since writing this post slightly.

    I require all the information after the 2nd "." to also be returned.

    e.g. E.123.01.01

    Should be E.000123.01.01

    I have uploaded a file with more examples. Can the formulas you orignally provided be amended to include this addition?
    Attached Files Attached Files

  6. #6
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Counting and substituting

    Aha..Try

    =LEFT(D4,2)&TEXT(MID(SUBSTITUTE(D4,".",REPT(" ",255),2),3,255),"000000")&TRIM(RIGHT(SUBSTITUTE(D4,".",REPT(" ",255)&".",2),255))

  7. #7
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Counting and substituting

    Perfect - thanks So much Ace

  8. #8
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373

    Re: Counting and substituting

    Another option, expanding my formula:

    =LEFT(D4,2)&TEXT(MID(D4,3,FIND(".",D4,3)-3),"000000")&MID(D4,FIND(".",D4,3),LEN(D4))

+ 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. Substituting text
    By skatcb in forum Excel General
    Replies: 2
    Last Post: 06-15-2012, 08:04 AM
  2. Substituting cells formula???
    By olisim in forum Excel General
    Replies: 11
    Last Post: 04-25-2010, 12:28 PM
  3. Substituting text
    By TedH in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-15-2009, 03:31 PM
  4. [SOLVED] Substituting numbers
    By Hugh in forum Excel General
    Replies: 4
    Last Post: 02-02-2006, 08:45 AM
  5. Substituting #N/A
    By SamuelT in forum Excel General
    Replies: 3
    Last Post: 01-11-2006, 10:04 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