Excel DATEVALUE function independent of international settings

后端 未结 2 1111
我寻月下人不归
我寻月下人不归 2021-01-15 03:52

In my Excel workbook, I copy some date information from another (text) source. To be able to do calculations with these dates, I use the function \"DATEVALUE\".

Exam

2条回答
  •  时光说笑
    2021-01-15 04:02

    Try the following UDF :

    Public Function EngDate(s As String) As Date
        Dim dayz As Long, monthz As Long, yearz As Long
        ary = Split(LCase(s), " ")
        dayz = CLng(ary(0))
        yearz = CLng(ary(2))
        mnth = Split("january,february,march,april,may,june,july august,september,october,november,december", ",")
        For i = 0 To 11
            If ary(1) = mnth(i) Then
                monthz = CLng(i + 1)
                Exit For
            End If
        Next i
        EngDate = DateSerial(yearz, monthz, dayz)
    End Function
    

    It will process inputs like:

    day as number, single space, month as text, single space, year as a number

提交回复
热议问题