Find if Excel is using US or UK date format

WaqasTariq

Board Regular
Joined
Jun 26, 2012
Messages
54
Office Version
  1. 365
Hi,
Is there anything in Excel VBA that will identify the current date format of Excel?

I am writing a macro and the people who will use it will be in the US and UK. I do not want to create two different solutions. Is there a way I can know what date format Excel is using so that I can base my rest of the code on that information?
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
You can use the Application.International property (Excel) with xlDateOrder

For example

VBA Code:
Option Explicit

Sub Sample()
    Dim DateOrderType As Integer
    
    DateOrderType = Application.International(xlDateOrder)
    
    Select Case DateOrderType
        Case 0: Debug.Print "M-D-Y"
        Case 1: Debug.Print "D-M-Y"
        Case 2: Debug.Print "Y-M-D"
    End Select
End Sub
 
Upvote 0
Solution
You can use the Application.International property (Excel) with xlDateOrder

For example

VBA Code:
Option Explicit

Sub Sample()
    Dim DateOrderType As Integer
   
    DateOrderType = Application.International(xlDateOrder)
   
    Select Case DateOrderType
        Case 0: Debug.Print "M-D-Y"
        Case 1: Debug.Print "D-M-Y"
        Case 2: Debug.Print "Y-M-D"
    End Select
End Sub
Thank you, that worked perfectly!
 
Upvote 0

Forum statistics

Threads
1,214,617
Messages
6,120,541
Members
448,970
Latest member
kennimack

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top