Converting text into a date using Vlookup

jnathan

New Member
Joined
Jul 8, 2013
Messages
48
I am attempting to extract a date from a cell that is in string format using a particular VLOOKUP.

This is the VLOOPUP statement (it works!)
Code:
Target.Offset(0, 20) = Evaluate("=VLOOKUP(" & Chr(34) & Target.Value & Chr(34) & ",'[Volume Alerts.xlsm] Data'!$A:$W,20,FALSE)")

The date is showing in the 20th column of the Data worksheet in the following format '20140923 08:03:38'

I need the VLOOKUP to be adapted so that it continues to pull in the data in the 20th column but converts it into date format dd/mm/yyyy.

Any help would be much appreciated!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Add this line after the VLookUp to display the date in the preferred format.

Target.Offset(0, 20).CellFormat = "dd/mm/yyyy hh:mm:ss"
 
Upvote 0
Assuming data in cell A1:

=DATE(YEAR(TEXT(LEFT(A1,FIND(" ",A1)),"0000-00-00")+0), MONTH(TEXT(LEFT(A1,FIND(" ",A1)),"0000-00-00")+0), DAY(TEXT(LEFT(A1,FIND(" ",A1)),"0000-00-00")+0))
 
Upvote 0
Assuming data in cell A1:

=DATE(YEAR(TEXT(LEFT(A1,FIND(" ",A1)),"0000-00-00")+0), MONTH(TEXT(LEFT(A1,FIND(" ",A1)),"0000-00-00")+0), DAY(TEXT(LEFT(A1,FIND(" ",A1)),"0000-00-00")+0))

Is anyone able to show me how the suggested solutions can 'live' within the code?

Code:
Target.Offset(0, 20) = Evaluate("=VLOOKUP(" & Chr(34) & Target.Value & Chr(34) & ",'[Volume Alerts.xlsm] Data'!$A:$W,20,FALSE)")
 
Upvote 0
Try this...

Code:
result = Evaluate("=VLOOKUP(" & Chr(34) & Target.Value & Chr(34) & ",'[Volume Alerts.xlsm] Data'!$A:$W,20,FALSE)")
result = Replace(result, "'", "")
Target.Offset(0, 20) = [color=darkblue]CDate[/color](Format(Split(result)(0), "0000-00-00")) + [color=darkblue]CDate[/color](Split(result)(1))
Target.Offset(0, 20).NumberFormat = "dd/mm/yyyy hh:mm:ss"
 
Upvote 0
Try this...

Code:
result = Evaluate("=VLOOKUP(" & Chr(34) & Target.Value & Chr(34) & ",'[Volume Alerts.xlsm] Data'!$A:$W,20,FALSE)")
result = Replace(result, "'", "")
Target.Offset(0, 20) = [COLOR=darkblue]CDate[/COLOR](Format(Split(result)(0), "0000-00-00")) + [COLOR=darkblue]CDate[/COLOR](Split(result)(1))
Target.Offset(0, 20).NumberFormat = "dd/mm/yyyy hh:mm:ss"

Thanks!!!! Works a treat.
 
Upvote 0
Try this...

Code:
result = Evaluate("=VLOOKUP(" & Chr(34) & Target.Value & Chr(34) & ",'[Volume Alerts.xlsm] Data'!$A:$W,20,FALSE)")
result = Replace(result, "'", "")
[COLOR=#FF0000][B]Target.Offset(0, 20) = CDate(Format(Split(result)(0), "0000-00-00")) + CDate(Split(result)(1))[/B][/COLOR]
Target.Offset(0, 20).NumberFormat = "dd/mm/yyyy hh:mm:ss"
Another way to write the red highlighted line...

Target.Offset(0, 20) = CDate(Format(result, "@@@@-@@-@@@@@@@@@"))

I am not sure where the apostrophe is that you are removing with your second line of code, so I don't know if that line of code is needed or not.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top