Here are two examples of parsing the text string you provided....
Code:
'-------------------------------------------------
' Doesn't use the 'Resolution Time' field
'-------------------------------------------------
Public Sub ParseResolution()
Dim String2Search As String
Dim pos As Integer
pos = 1
'String2Search = "03/01/2010 10:30:01 Case has been closed 03/01/2010 10:15:22 User restarted computer and all is working ok 03/01/2010 10:10:11 User called to advise that they are unable to access their network drives"
String2Search = "03/01/2010 10:30:01 Case has been closed 03/01/2010 10:15:22 User restarted computer and all is working ok 03/01/2010 10:10:11 User called to advise that they are unable to access their network drives"
'find first colon
pos = InStr(pos, String2Search, ":") + 1
'find second colon
pos = InStr(pos, String2Search, ":") + 1
'find third colon
pos = InStr(pos, String2Search, ":") + 1
'find fourth colon
pos = InStr(pos, String2Search, ":") + 2
'cut off first part of string
String2Search = Mid(String2Search, pos)
'now locate the end of the string
pos = 1
pos = InStr(pos, String2Search, "/")
pos = pos - 3
'cut off back part of string
String2Search = Trim(Left(String2Search, pos))
MsgBox String2Search
End Sub
Code:
'-------------------------------------------------
' Uses the 'Resolution Time' field
'-------------------------------------------------
Public Sub ParseResolution2()
Dim String2Search As String
Dim SearchFor As String
Dim pos As Integer
pos = 1
'String2Search = "03/01/2010 10:30:01 Case has been closed 03/01/2010 10:15:22 User restarted computer and all is working ok 03/01/2010 10:10:11 User called to advise that they are unable to access their network drives"
String2Search = "03/01/2010 10:30:01 Case has been closed 03/01/2010 10:15:22 User restarted computer and all is working ok 03/01/2010 10:10:11 User called to advise that they are unable to access their network drives"
' Get date/time from 'Resolution Time' field
'SearchFor = address for 'Resolution Time' in excel
SearchFor = "03/01/2010 10:15:22" ' <<<< hard code for now
'locate the start of string to keep
pos = InStr(pos, String2Search, SearchFor) + 20
'cut off first part of string
String2Search = Mid(String2Search, pos)
'now locate the end of the string
pos = 1
pos = InStr(pos, String2Search, "/")
pos = pos - 3
'cut off back part of string
String2Search = Trim(Left(String2Search, pos))
MsgBox String2Search
End Sub
Note that there is not any Error Handling code in the examples
.