Reputation: 77
In Excel VBA I am assigning a hard coded date to a named range as below:
Worksheets("Main").Range("Effectivedate").Value ="11/12/2018"
This is been triggered on a button Click. Now I have my system culture as UK. When I click the button the value populated on the cell is "12/11/2018". If I change the culture to US then it get populated as "11/12/2018".
As my application is been used between US and UK countries, I would like to know is there a way assign the date as such t the cell without formatting.
Upvotes: 0
Views: 1265
Reputation: 84465
I would suggest using an umambiguous data format ("yyyy-mm-dd") like
"2018-12-11"
Can you otherwise try:
Option Explicit
Sub test()
With Worksheets("Main").Range("Effectivedate")
.Value = 43445
.NumberFormat = "dd/mm/yyyy"
End With
End Sub
Upvotes: 4