作者:手机用户2602881147 | 来源:互联网 | 2023-09-15 17:55
ImusingCDatetoconvertaparticulardateformattedasstringtotheExcelDatetype.Iwroteas
I'm using CDate to convert a particular date formatted as string to the Excel Date type. I wrote a small UDF for this conversion; however when I run the function as a in-cell function, it returns a number and the calling cells default format is set to Number type. When I manually convert it to Date type, Excel will display the correct date entry.
我正在使用CDate将格式化为字符串的特定日期转换为Excel日期类型。我为这次转换写了一个小UDF;但是当我将该函数作为单元格函数运行时,它返回一个数字,并且调用单元格的默认格式设置为数字类型。当我手动将其转换为日期类型时,Excel将显示正确的日期条目。
So, I need to know whether there is a way to set the default format of the calling cell to Date type through my Date conversion macro. Otherwise, the user has to manually change the format of each of cell.
所以,我需要知道是否有办法通过我的日期转换宏将调用单元格的默认格式设置为日期类型。否则,用户必须手动更改每个单元格的格式。
e.g
例如
Function Test()
Test = CDate("2010/12/23")
End Function
4 个解决方案