for example i have "journal id expired on - Jul 5/10
i need the part Ju 5/ 10
ie after "-"
how to write in vba code
thanks for your help
Printable View
for example i have "journal id expired on - Jul 5/10
i need the part Ju 5/ 10
ie after "-"
how to write in vba code
thanks for your help
try likevb Code:
mystr = "journal id expired on - Jul 5/10" mystr = mid(mystr, instr(mystr, "-" + 1))
One more way... Using Split()
Code:Sub Sample()
Dim StrSample As String, MyArray() As String
StrSample = "journal id expired on - Jul 5/10"
MyArray = Split(StrSample, "-")
MsgBox MyArray(1)
End Sub
hi Kool and westconn
both i tried it gives type mismatch
Show us the exact code that you are using?
Kool
sorry i missed MyArray () as string
thanks it works fine. i need another help
how do compare MyArray with Cell(a)
Cell (a) = 08/15/2010 8:18
thanks
I am sorry, I do not understand. Can you explain it a bit more on what you want to do?
for example
compareMyarray to Cell (1)
MyArray as string and Cell(1) format as m/d/yyyy h:mm
how do i compare both
You mean if Cell say A1 has "7/5/2010 8:18:00" and you want to compare the value stored in the array then do this...
Code:Sub Sample()
Dim StrSample As String, MyArray() As String, Temp As String
StrSample = "journal id expired on - Jul 5/10"
MyArray = Split(StrSample, "-")
'~~> A1 = 7/5/2010 8:18:00
Temp = Trim(Format(Range("A1"), "mmm d/yy"))
If Trim(MyArray(1)) = Temp Then
MsgBox "match found"
Else
MsgBox "match not found"
End If
End Sub