+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Forum Contributor
    Join Date
    10-18-2003
    Posts
    22

    Replace 3 Digits with Letter

    Hi,

    I often refer to the following number format in emails: (XXX-XXXXXX). The first three numbers in each string need to be replaced with a prefix (there are currently about 10 different prefixes in use. I would like to change the prefix to a Letter. For example, I would like to replace 123-456789 with A-456789 and I would like to switch 234-567891 with B-567891 etc.

    Is there a code I could employ to automatically swap out the first three numbers for the letter whenever entered in an email? Thanks.

  2. #2
    Forum Contributor
    Join Date
    08-19-2006
    Posts
    116

    Re: Replace 3 Digits with Letter

    Hi,

    There is a similar thread on this forum but i do not know where and i do not remember how to do exactly.It is something like
    Ctrl+H
    Find:[!4-9]
    Replace:A

    Before Ok,you have to check the following option:Use...
    Last edited by Raiby; 11-10-2009 at 02:39 PM. Reason: deleted spurious quote

  3. #3
    Registered User
    Join Date
    11-09-2008
    Location
    germany
    Posts
    74

    Re: Replace 3 Digits with Letter

    Quote Originally Posted by Scottmk View Post
    Hi,

    I often refer to the following number format in emails: (XXX-XXXXXX).
    First if you are not using Outlook to read your email body you are going to get security messages from Outlook saying that a program is trying to read your emails.

    Next I think the trick here is going to be to extract your string out first ie XXX-XXXXXX

    I would suggest you look at the LIKE function for example to test if the body of your email has this pattern in it at all you would use

    If myBody Like ("*###[-]######*") = True then
    do something
    end if

    Then to extract your string out something like this might work for mysubject or mybody

    Code:
    If mysubject Like ("*###[-]######*") = True Then
            For i = 1 To Len(mysubject) - 9
                If Mid(mysubject, i, 10) Like ("###[-]######") Then
                    yourstring = Mid(mysubject, i, 10)
                     or do here what you want with it before you loop again
                End If
            Next
        End If

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.2.0