+ Reply to Thread
Results 1 to 4 of 4

TRANSLATE as an Excel UDF

  1. #1
    Forum Contributor Gregor y's Avatar
    Join Date
    10-24-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2010 32-Bit
    Posts
    276

    TRANSLATE as an Excel UDF

    TRANSLATE is a handy function available in some flavors of SQL to help with data cleansing

    Here is a version written as an Excel UDF so that it can be used in cell formulas
    Please Login or Register  to view this content.
    Note: In this version if the character list is longer than the translation list then those are assumed to be ones you want to remove.

  2. #2
    Forum Contributor Gregor y's Avatar
    Join Date
    10-24-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2010 32-Bit
    Posts
    276

    Re: TRANSLATE as an Excel UDF

    A couple usage examples:

    delimiter standardization
    A
    B Formula
    B Value
    1 EA1-BX5-PK10 =translate(A1,"\-","//") EA1/BX5/PK10
    2 EA1\BX5\PK10 =translate(A2,"\-","//") EA1/BX5/PK10
    3 EA1/BX5/PK10 =translate(A3,"\-","//") EA1/BX5/PK10

    problem characters removal/avoidance
    A
    B Formula
    B Value
    1 description\ =translate(A1,"\|"&CHAR(13)&CHAR(9)&CHAR(10),"/"&CHAR(166)&" ") description/
    2 new
    line
    =translate(A2,"\|"&CHAR(13)&CHAR(9)&CHAR(10),"/"&CHAR(166)&" ") new line
    3 no tab =translate(A3,"\|"&CHAR(13)&CHAR(9)&CHAR(10),"/"&CHAR(166)&" ") no tab
    4 pipe|to bar =translate(A4,"\|"&CHAR(13)&CHAR(9)&CHAR(10),"/"&CHAR(166)&" ") pipe¦to bar
    Last edited by Gregor y; 01-19-2023 at 04:11 PM. Reason: typo, forum posting issues

  3. #3
    Forum Contributor Gregor y's Avatar
    Join Date
    10-24-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2010 32-Bit
    Posts
    276

    Re: TRANSLATE as an Excel UDF

    Unfortunately it's not quite that simple, since it doesn't pass the translate vs replace test...

    A
    B Formula
    B Value
    B Expected
    1 abcdef =translate(A1,"abc","bcd") ddddef bcddef
    2 abcdef =translate2(A2,"abc","bcd") bcddef bcddef

    but it can be fixed

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    02-21-2023
    Location
    London, UK
    MS-Off Ver
    Microsoft Office 2016 x64
    Posts
    10

    Re: TRANSLATE as an Excel UDF

    Thank you for sharing this!

+ 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. Macro: translate text from cell using google translate
    By Marc_excel_tips in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 01-05-2021, 06:18 AM
  2. Translate English to French without using Google Translate
    By shaunafink in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-29-2019, 12:08 PM
  3. Translate text from cell using Google translate (2)
    By Andreea1234 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-31-2019, 07:36 AM
  4. Replies: 3
    Last Post: 04-29-2016, 04:10 AM
  5. Sample Translate English to Arabic Text Using MS Translate
    By pidyok in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-21-2013, 08:18 AM
  6. [SOLVED] Translate excel formulae
    By Helen in forum Excel General
    Replies: 3
    Last Post: 06-16-2005, 03:05 PM
  7. Translate Excel Formulas
    By cradino in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-17-2005, 08:17 AM

Tags for this Thread

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