
文字列から日付や時刻値を取得するマクロです。
DateValue
文字列から日付値を取得するには、DateValue関数を使います。Sub GetDateValue() MsgBox Format(DateValue("2017/08/01"), "yyyy/mm/dd hh:nn:ss") End Sub
実行結果

DateValueで日付値を求めた場合、時刻は00:00:00になります。
TimeValue
文字列から時刻値を取得するには、TimeValue関数を使います。Sub GetTimeValue() MsgBox Format(TimeValue("10:10"), "yyyy/mm/dd hh:nn:ss") End Sub
実行結果

TimeValueで時刻値を求めた場合、日付は1899/12/30になります。これはVBAで1899/12/30のシリアル値が0となっているためです。
<参考サイト>
DateValue 関数 | Office VBA 言語リファレンス
TimeValue 関数 | Office VBA 言語リファレンス
スポンサーリンク