+ Reply to Thread
Results 1 to 9 of 9

Replace sepcific text with specific numbers

  1. #1
    Registered User
    Join Date
    02-12-2016
    Location
    Zurich, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    94

    Replace sepcific text with specific numbers

    Hi everyone,

    In the attached excel I have the problem that the date are not displayed in a consistent way.

    In columns C and D the month March, May October and December are not displayed in the right way. It is displayed as 01.Mar.2016 when it should display 01.03.2016 .

    I would need an easy way, preferably with a macro, that replaces for these months the text with the corresponding month number. For example for March, replace Mar with 03, May with 05, Oct with 10, Dec with 12. In that I can actually compute the days by subtracting C from D.

    Many thanks for your help.

    Best regards,
    Enrico
    Attached Files Attached Files

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Replace sepcific text with specific numbers

    Hi Enrico,

    No need for VBA when an Excel formula will do the trick. Here is the formula in F2
    Please Login or Register  to view this content.
    Pull this formula in F2 over to G2 and then autofill down to the bottom. Then copy and paste columns F and G over C and D using Values Only and format cells to date.

    See the attached.
    DateValue fixer on some months.xlsx
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor IonutC's Avatar
    Join Date
    01-28-2016
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2019
    Posts
    486

    Re: Replace sepcific text with specific numbers

    Hi,

    If yu need a macro use this and edit it accordingly.

    Please Login or Register  to view this content.
    Please consider:
    Be polite. Thank those who have helped you.
    Click the star icon in the lower left part of the contributor's post and add Reputation. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .
    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Posting code between tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

  4. #4
    Registered User
    Join Date
    02-12-2016
    Location
    Zurich, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    94

    Re: Replace sepcific text with specific numbers

    Hi Marvin P

    Unfortunately, that doesn't work for me. I would rather do it with a replacing as columns A, B, C, D and E are from an external source and updated every week. Once copied in, I would prefer a button that I can assign a macro to which replaces the text months to numbers.

  5. #5
    Registered User
    Join Date
    02-12-2016
    Location
    Zurich, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    94

    Re: Replace sepcific text with specific numbers

    Thanks a lot, but It should only replace in columns C and D, not the entire worksheet (so not in the names for instances that are in columsn A and B).

  6. #6
    Forum Contributor IonutC's Avatar
    Join Date
    01-28-2016
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2019
    Posts
    486
    Quote Originally Posted by etaver87 View Post
    Hi Marvin P

    Unfortunately, that doesn't work for me. I would rather do it with a replacing as columns A, B, C, D and E are from an external source and updated every week. Once copied in, I would prefer a button that I can assign a macro to which replaces the text months to numbers.
    Etaver use my macro and will do the Job. You can assign it to a button and all is fine.

  7. #7
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Replace sepcific text with specific numbers

    Not sure why there is a problem but with this simple formula I was able to convert all dates without any issues.
    Please see attached file.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  8. #8
    Registered User
    Join Date
    02-12-2016
    Location
    Zurich, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    94

    Re: Replace sepcific text with specific numbers

    Quote Originally Posted by IonutC View Post
    Etaver use my macro and will do the Job. You can assign it to a button and all is fine.
    That's what I would love and it works for the whole sheet but I only need to find/replace in columns C and D. Is that possible?

  9. #9
    Forum Contributor IonutC's Avatar
    Join Date
    01-28-2016
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2019
    Posts
    486

    Re: Replace sepcific text with specific numbers

    try this one
    Please Login or Register  to view this content.

+ 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. Lookup & replace specific text in a text string
    By Haha88 in forum Excel General
    Replies: 1
    Last Post: 07-13-2015, 06:06 PM
  2. How to replace numbers and text in a cell with just text
    By Brandonjay in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-14-2015, 10:47 AM
  3. Replies: 2
    Last Post: 04-10-2015, 12:12 PM
  4. [SOLVED] Search through columns and find specific text and replace that text with header column
    By adamzee in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-09-2014, 11:59 PM
  5. Replacing specific text in a cell by row and replace with text in another row
    By merQrey in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-23-2014, 10:05 AM
  6. How do I replace text with numbers?
    By njlatino85 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-19-2012, 05:01 PM
  7. [SOLVED] Replace text in specific column
    By Gijs Breedveld in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-19-2006, 02:15 PM

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