次の形式のExcelシートにデータがあります。
ItemCode DeliveryDate 54569872009年1月24日 5456988 54569892009年12月24日 54569902009年12月24日
DeliveryDateの値を配列に格納しました。日付の基本を決めて、結果を新しいシートに印刷する必要があります。したがって、値を配列に変換する必要があります。
Dim current as Date, highest as Date, result() as Date
For Each itemDate in DeliveryDateArray
current = CDate(itemDate)
if current > highest then
highest = current
end if
' some more operations an put dates into result array
Next itemDate
'After activating final sheet...
Range("A1").Resize(UBound(result), 1).Value = Application.Transpose(result)
残念ながら、CDate()関数は次のエラーをスローします。
実行時エラー「13」:
型の不一致
VBAには次のような機能がありますか?
- 任意の日付形式で文字列を解析し、操作する日付オブジェクトを返します。
- 文字列が空または不正な形式の場合(ループでの比較のため)、空の日付オブジェクトを返します。
編集:
エラーを再現するには、単に実行します
myDate = CDate("24.01.2009")