Why does transposing array with dates in format dd/mm/yy change some dates to mm/dd/yy format?

后端 未结 3 1969
隐瞒了意图╮
隐瞒了意图╮ 2021-01-07 09:39

Behavior:

When I transpose a 1 dimensional array, containing dates, in order to print them to a sheet in it\'s entirety, some dates are changed from the dd/m

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-07 10:20

    I hit this problem, but interestingly, the date switch (from dd/mm to mm/dd) on transpose only happened when I ran the macro from a toolbar button; if I ran it from inside the VBA editor, or from the Developer menu>Macros dialogue box, it worked fine. To make it work no matter where I ran the macro from, I added a function before the transpose to convert all dates to strings (looping through my array and using the CStr function), and then converted back from strings to dates after the transpose (another loop and CDate function) - the loops having to be slightly different to account for the transposed dimensions.

提交回复
热议问题