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..
 

Some videos you may like

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

texasalynn

Well-known Member
Joined
May 19, 2002
Messages
8,458
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
 
L

Legacy 68668

Guest
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,656
Messages
5,597,390
Members
414,141
Latest member
Joey_T92

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
Top