substring help

Maha

New Member
Joined
Mar 25, 2009
Messages
13
Hi,

I need to extract substring from a cell.For example if i have a value show below in one cell:

Sub=Message from HeepLine & body=Msg ID: 4523_2
pls check job seek.c failed
This email message is confidential


I need to extract the Msg Id and body of the msg(here, pls check job seek.c failed). how to do this using macro?
Pls help me out..
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
try this

Code:
Sub FindText()
MsgID = InStr(Cells(18, 1), ":")
Msgd = Len(Cells(18, 1)) - InStr(Cells(18, 1), "This")
Msgdtl = Mid(Cells(18, 1), MsgID + 1, Msgd)
MsgBox "Msg: " & Msgdtl
End Sub
 
Upvote 0
try
=GetIDBody(A1)
Code:
Function GetIDBody(ByVal txt As Strig) As String
Dim x
x = Split(txt, vbLf)
GetIDBody = Mid$(x(0), InStrRev(x(0), " ")) & " " & x(1)
End Function
 
Upvote 0

Forum statistics

Threads
1,214,385
Messages
6,119,208
Members
448,874
Latest member
b1step2far

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top