+ Reply to Thread
Results 1 to 4 of 4

Use of the MID function

  1. #1
    Forum Contributor
    Join Date
    06-12-2006
    Location
    Portugal
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    212

    Use of the MID function

    I have a lot of these strings in each cell:

    CHEQUE DEPOSITADO NESTA I.CREDITO N. 4378319839

    The are not always equal, the number of charecters can change a lot. How do i use the MID function to allways extract to another column the 8 last figures less the two last ones.
    In this case, the number be extracted should be 783198. Please note that, as i said, the strings size can vary, but the figures allways come in the end.

    Thanks a lot

  2. #2
    Marcelo
    Guest

    RE: Use of the MID function

    Hi Teixiera,

    De acordo com o texto da sua mensagem você deve enteder Português,
    copie e cole o módulo abaixo (ALT+F11).

    use a função =digitsonly(a2) na coluna ao lado, você somente terá os números
    lá.

    use a função MID

    espero ter ajudado
    um abraço do Brazil
    Marcelo


    **********************************************
    Public Function DigitsOnly(sStr As String) As Variant
    Dim oRegExp As Object

    Set oRegExp = CreateObject("VBScript.RegExp")

    With oRegExp
    .IgnoreCase = True
    .Global = True
    oRegExp.Pattern = "\D"

    DigitsOnly = oRegExp.Replace(sStr, vbNullString)
    End With
    End Function
    **************************************************



    "oteixeira" escreveu:

    >
    > I have a lot of these strings in each cell:
    >
    > CHEQUE DEPOSITADO NESTA I.CREDITO N. 4378319839
    >
    > The are not always equal, the number of charecters can change a lot.
    > How do i use the MID function to allways extract to another column the
    > 8 last figures less the two last ones.
    > In this case, the number be extracted should be 783198. Please note
    > that, as i said, the strings size can vary, but the figures allways
    > come in the end.
    >
    > Thanks a lot
    >
    >
    > --
    > oteixeira
    > ------------------------------------------------------------------------
    > oteixeira's Profile: http://www.excelforum.com/member.php...o&userid=35320
    > View this thread: http://www.excelforum.com/showthread...hreadid=564310
    >
    >


  3. #3
    tim m
    Guest

    RE: Use of the MID function

    =MID(A1,LEN(A1)-7,6)

    See if this does the trick for you.

    "oteixeira" wrote:

    >
    > I have a lot of these strings in each cell:
    >
    > CHEQUE DEPOSITADO NESTA I.CREDITO N. 4378319839
    >
    > The are not always equal, the number of charecters can change a lot.
    > How do i use the MID function to allways extract to another column the
    > 8 last figures less the two last ones.
    > In this case, the number be extracted should be 783198. Please note
    > that, as i said, the strings size can vary, but the figures allways
    > come in the end.
    >
    > Thanks a lot
    >
    >
    > --
    > oteixeira
    > ------------------------------------------------------------------------
    > oteixeira's Profile: http://www.excelforum.com/member.php...o&userid=35320
    > View this thread: http://www.excelforum.com/showthread...hreadid=564310
    >
    >


  4. #4
    Forum Contributor
    Join Date
    06-12-2006
    Location
    Portugal
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    212

    MID function

    Obigado Marcelo. Está perfeito. Tentei com MID , RIGHT, etc. Mas nada deu...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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