How to convert a text field into a date field with VBA

When you get a date from BEx Analyzer or Analysis Office the Excel internal format is Text and not Date. This means that the sorting doesn't work correctly. Use the following VBA source code to convert easily text to date.


Sub Text_to_Date()

Dim dDate As Date

Dim dRange As Range

Set dRange = Range(Selection.Address)

For Each Cell In dRange

If IsDate(Cell.Value) Then

dDate = Cell.Value

Cell.Value = dDate

End If


End Sub

Write a comment

Comments: 0