How to Convert Date Format from Dot MM.DD.YYYY to Slash MM/DD/YYYY in Excel

We often enter dates in excel tables, and we can enter current date by quickly press ‘Ctrl+;’ simultaneously. If in some cases we enter a date format that is not what we want, we have to switch the date format manually, for example if the date format is DD.MM.YYYYY, but we want to use the slash to display date like DD/MM/YYYY, how can we do? This article will show you two methods to convert the data format by formula and VBA code, you can select one you like to convert date format.

Convert Date Format from Dot to Slash by Formula


Frist, we prepare a list of dates in worksheet. See screenshot below.

Convert Date Format from Dot to Slash 1

Step 1: Actually, to convert the separator you just need to replace DOT by SLASH in date format, so we can use SUBSTITUTE function here. In B1, enter the formula =SUBSTITUTE(A1,”.”,”/”).

Convert Date Format from Dot to Slash 2

Step 2: Click Enter to get the result.

Convert Date Format from Dot to Slash 3

Step 3: Fill the following cells A2:A5 by dragging the fill handle. Then date format is displayed as DD/MM/YYYY for all entered dates properly.

Convert Date Format from Dot to Slash 4

Convert Date Format from Dot to Slash by VBA Code


Step 1: Click Developer tab->Visual Basic or Alt+F11 to load Microsoft Visual Basic for Applications window. You can also right click on current sheet1 tab and select View Code to open Microsoft Visual Basic for Applications.

Convert Date Format from Dot to Slash 5

 Step 2: Enter below code into the window.

Private Sub Worksheet_Change(ByVal MyRange As Range)

    On Error Resume Next

    Application.EnableEvents = False

    If Not (Intersect(MyRange, Me.Range("A1:A5")) Is Nothing) Then

        MyRange.Value = Replace(MyRange.Value, ".", "/")

    End If

    Application.EnableEvents = True

End Sub

Screenshot below:

Convert Date Format from Dot to Slash 6

Step 3: Save above code and close Microsoft Visual Basic for Applications. Then in A1, enter a date with format DD.MM.YYYY, then click Enter in the cell, you can find that date format is changed to DD/MM/YYYY directly.

Notes:

  1. Above code is only activated for range A1:A5.
  2. Be aware that range A1:A5 is customed, you can expand the range and make sure the range can cover all entered dates.

Related Functions


  • Excel Substitute function
    The Excel SUBSTITUTE function replaces a new text string for an old text string in a text string.The syntax of the SUBSTITUTE function is as below:= SUBSTITUTE  (text, old_text, new_text,[instance_num])….


Related Posts

Find and Replace Multiple Values

This post will guide you how to find and replace multiple values at once with VBA macro or using formula  in Excel. How do I make multiple find and replace in Excel. Suppose that you have a few cells containing ...

Extract Last Two Words From Multiple Cells

Just assume that you have a few cells containing values/words and you want to extract the last two words from each cell into another separate cell; then you might think that it's not a big deal; because you would prefer ...

Extract Multiple Lines From A Cell

Suppose that you have listed some text in a single cell which is separated by the line break(you can do it by pressing ALT + ENTER after entering the text), and now you want to extract multiple lines of text ...

How to Remove All Asterisk Characters from Cells in Excel

Sometimes when we opening an excel spreadsheet to check data, we may notice that there are some asterisks exist in texts for security or other reasons. If you feel these special characters are invalid you can remove them from cells. ...

How to Remove Quotes for Text or Strings in Excel

When we importing data from other source into Excel we may import quotes or quotations from initial file. And we want to remove these quotes from current file, if we remove them one by one it needs a lot of ...

Sidebar