|
こんにちは。
今度は、日付について質問です。
1列目のセルにInbook_day(例2004/02/20)と同じ日付が
あるか検索するとき、空白セルもイコールとして認識してしまいます。
何故でしょうか?
Function Shuukei(book_path3) As String
Dim Inbook_name As String
Dim Inbook_day As String
Dim Inbook_name2 As String
Dim day1 As String
Dim day2 As String
Dim day3 As String
Dim gyou As Integer
Dim retu As Integer
Dim cell As Date
Dim book As Date
Dim i As Integer
'//入力ファイルの日付をm月d日に変更//
Inbook_name = Dir(book_path3, vbNormal)
MsgBox Inbook_name
Inbook_name2 = Left(Inbook_name, 6)
day1 = Mid(Inbook_name2, 1, 2)
day2 = Mid(Inbook_name2, 3, 2)
day3 = Mid(Inbook_name2, 5, 2)
Inbook_day = day1 + Chr(47) + day2 + Chr(47) + day3
Inbook_day = CDate(Inbook_day)
'Inbook_day = Format(Inbook_day, "m月d日")
MsgBox Inbook_day
'//ファイルのOPEN//
Workbooks.Open (book_path3 & Inbook_name)
Workbooks.Open (book_path3 & "QAC集計(CABC).xls")
'//最終入力セルに移動し行の取得//
Workbooks("QAC集計(CABC).xls").Worksheets("CABC"). _
Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Select
gyou = Workbooks("QAC集計(CABC).xls").Worksheets("CABC"). _
Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row
MsgBox gyou
book = ActiveSheet.Cells(gyou, 1).Value
MsgBox book
Do Until gyou = 1
gyou = gyou - 1
ActiveSheet.Cells(gyou, 1).Select
book = ActiveSheet.Cells(gyou, 1).Value
Select Case book
Case book < Inbook_day
MsgBox "小さい"
Exit Do
Case book = "0:00:00"
gyou = gyou - 1
Case book = Inbook_day ・・・ここで空白セルを認識
Exit Do
End Select
Loop
MsgBox gyou
End Function
ここで、1列目は、すべて日付型にしています。
宜しくお願いします。
|
|