Date Format wrong when Transfering From Array To Range

drom

Well-known Member
Joined
Mar 20, 2005
Messages
543
Office Version
  1. 2021
  2. 2019
  3. 2016
  4. 2013
  5. 2011
  6. 2010
  7. 2007
Hi and thanks in advance!



This Macro is just for this eg, but the macro shows my problem

Code:
Sub AAAa()
Dim aDates(1 To 3)
'The Formatting of the selection is = [$-en-GB]dd/mmm/aaaa;@
  aDates(1) = Selection.Cells(1)      '= "01/11/2018"     = 01/Nov/2018
  aDates(2) = Selection.Cells(2)      '= "23/11/2018"     = 23/Nov/2018
  aDates(3) = Selection.Cells(3)      '= "05-04/2019"     = 05/Apr/2019
'The Formatting of the "L1:L3" is = [$-en-GB]dd/mmm/aaaa;@
Range("L1:L3") = Application.WorksheetFunction.Transpose(aDates)
'L1:L3 shows:
  'L1 = 11/Jan/2018
  'L2 = 23/11/2018
  'L3 = 04/May/2019
End Sub

How Can I solve this?

This Macro is just a draft of a huge macro I am using this is why I have decided to show just the problem briefly

ps:
Please I do know I can use:
  • range("L1")= Selection.Cells(1)
  • range("L2")= Selection.Cells(2)
  • range("L3")= Selection.Cells(3)
But this is not my question, I am trying to learn whats going on when transfering from array to range
and:

How can I solve this? Thanks again
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
The problem comes when using:
Application.WorksheetFunction.Transpose(aDates)
If I do create a second array to avoid Application.WorksheetFunction.Transpose the macro will work
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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