|
要求:对F\G\H\I列进行处理,将时间在11:30之前的放在F列,13:30之后的时间放在I列,11:30至13:30之间的时间放入H列。我写出了代码,运行后达不到效果,求大神指点- Sub test()
- Dim rng As Range, i As Integer, arr(1 To 4), item As Byte, my_val
- For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
- item = 1
- For Each rng In Range("F" & i).Resize(1, 4)
- arr(item) = rng.Value
- item = item + 1
- Next
- Range("F" & i).Resize(1, 4).Clear
- For Each my_val In arr
- If my_val <> "" Then
- If my_val < TimeValue("11:30:00") Then
- Cells(i, "F") = Format(my_val, "hh:mm")
- ElseIf 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
复制代码 |
|