|
噢,的确是丢失了,那是你输入数据的格式出了问题,所有的时间直接引用都>TimeValue("13:30:00"),最后一个数据覆盖了前面所有数据,再次填入后实际数据已经变了,第二次运行就正确了,但已丢失了一些数据,你自己调试一下就明白啦,所以要修改宏如下:
Sub test()
Dim i As Integer, arr, my_val
For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
arr = Range("F" & i & ":I" & i).Value
Range("F" & i).Resize(1, 4).Clear
For Each my_val In arr
If my_val <> "" Then
If TimeValue(my_val) < TimeValue("11:30:00") Then
Cells(i, "F") = Format(my_val, "hh:mm")
ElseIf TimeValue(my_val) > TimeValue("13:30:00") Then
Cells(i, "I") = Format(my_val, "hh:mm")
Else
Cells(i, "H") = Format(my_val, "hh:mm")
End If
End If
Next
Next
End Sub
|
|