我有一个这样的Excel工作表:
9/2/2018
3:00PM-11:00PM
full time(8hr) - 3 PM
3:00PM- 4:15PM
Immediate
4:15PM- 4:30PM
Break
4:30PM- 5:45PM
Immediate
5:45PM- 6:15PM
Break
6:15PM- 9:45PM
Immediate
9:45PM-10:00PM
Break
10:00PM-11:00PM
Immediate
所有这些都以相同的顺序放在一个单元格中 而我想将每个时间范围一一对应,并放在不同的单元格中?
the result should be like this
我想休息三个时间,像照片一样分开
答案 0 :(得分:1)
数据在 A1 中,在 B1 中输入:
=TRIM(MID(SUBSTITUTE($A1,CHAR(10),REPT(" ",999)),(2*COLUMNS($A:A)-1)*999-998,999))
并复制:
每个时间范围在其自己的单元格中。我们只是解析CHAR(10)
上的字符串,然后选择所有奇数项。
答案 1 :(得分:0)
我想花三个休息时间开始
您可以尝试
Function GetBreaksStartTime(txt As String)
Dim i As Long
Dim arr As Variant
arr = Split(txt, "Break")
If UBound(arr) > 0 Then
ReDim startTimes(1 To UBound(arr)) As String
For i = 1 To UBound(arr)
startTimes(i) = WorksheetFunction.Trim(Replace(Split(arr(i), "-")(0), vbLf, ""))
Next
GetBreaksStartTime = startTimes
End If
End Function
您可以在主代码中将其用作
Dim breaksStartTime As Variant, startTime as variant
breaksStartTime = GetBreaksStartTime(Range("A1").Value2)
For Each startTime in breaksStartTime
MsgBox startTime
Next