|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub test()
If MsgBox("运行代码需要一定时间;" & Chr(10) & "继续提取请按确定(结束会有提示),退出按取消。", 33, "提示信息") = vbCancel Then Exit Sub
T = Timer
isall = 1 '提取方式参数,当值为1时,提取所有日期时间,其它任意值提取最早日期时间
Application.ScreenUpdating = False
Sheet1.Columns("D:F").ClearContents
For i = 2 To Sheet1.Range("A" & Rows.Count).End(xlUp).Row
stri = Sheet1.Range("A" & i)
k = 4
Do
dip = InStr(stri, Chr(10))
If dip > 0 Then
st1 = Mid(stri, 1, dip)
If InStr(st1, "安排出车") > 0 Then
sj = FormatDateTime(Mid(st1, 1, 19))
With Sheet1.Cells(i, k)
.Value = sj
.NumberFormatLocal = "yyyy/m/d h:mm:ss" '显示格式
.Columns.AutoFit '自动列宽
End With
If isall = 1 Then k = k + 1
End If
stri = Mid(stri, dip + 1, Len(stri))
Else
If Len(stri) > 0 Then
If InStr(stri, "安排出车") > 0 Then
sj = Mid(stri, 1, 19)
With Sheet1.Cells(i, k)
.Value = sj
.NumberFormatLocal = "yyyy/m/d h:mm:ss" '显示格式
.Columns.AutoFit '自动列宽
End With
End If
stri = ""
End If
End If
If stri = "" Then Exit Do
Loop
Next
Application.ScreenUpdating = True
MsgBox "一共用时:" & Format(Timer - T, "#0.00") & " 秒", , "提取完毕!"
End Sub
|
评分
-
1
查看全部评分
-
|