How to use Windows regional date format in Excel vba

Ingemar

New Member
Joined
May 8, 2017
Messages
23
Office Version
  1. 365
Platform
  1. Windows
Dear all,

I have made a vba macro code to get date from Excel cells in a special format to be used for follow up.

ActiveCell.FormulaR1C1 = "=TEXT(RC[1],""ÅÅÅÅ-MM-DD"")"
ActiveCell.FormulaR1C1 = "=TEXT(RC[1],""YYYY-MM-DD"")"

In Sweden, Windows regional date format is ÅÅÅÅ-MM-DD. The letter Å stands for År which is Year in English. My colleagues abroad has a modified version of the macro which is YYYY-MM-DD.

I am trying to have only one universal version of the Excel macro and would like to have a code detecting the regional date setting from Windows operative system and use it in the macro. I am using Windows 10 and Microsoft Office 365.

Greatful for any suggestion or help

Kind regards

Ingemar
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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