- 1). Open the Microsoft Office application for which you're writing your script, and press "Alt" and "F11" at the same time to open the VBA editor. Select the VBA script you want to edit by left clicking it on the left navigation pane, which will open the code window to the right. The default script is open already, so if you want to edit that, you don't need to click anything in the navigation pane. Locate the function in the file you just opened that you want to convert a date, and place your cursor there.
- 2). Copy and paste the following code into your VBA function to define the string to be converted, substituting the desired date:
Dim strDate = "August 13th, 2010" - 3). Copy and paste the following code under the previous code, to initialize the date variable and convert the string:
Dim myDate
myDate = CDate(strDate)
MsgBox myDate - 4). Press "F5" to run your VBA code and see a message box appear with your converted date in it.
previous post