Unable to lookup a date using vba vlookup

房东的猫 提交于 2019-12-01 22:01:32

VLookup is sensitive to data types. And your VBA routine is looking for a DATE data type, but such does not exist on an Excel worksheet. So you need to convert your string lookup_value to a data type compatible with what is on the worksheet. This could be a Long (for whole dates) or Double (if you are including times.

Try:

the_day = WorksheetFunction.VLookup(CLng(CDate(lookup_value)), lookup_table, 2, False)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!