Extract tect from cell

sharky12345

Well-known Member
Joined
Aug 5, 2010
Messages
3,404
Office Version
  1. 2016
Platform
  1. Windows
Is there a way I can extract the word(s) after a specific word from a cell?

The contents of the cell are on numerous lines, so I would need something that searched the cell, finds the phrase 'INDEX:' and then grabs the word(s) after that, but on the same line only, and puts it/them into cell G4.

Anyone?
 
Rick - got it to extract what I need but I need to remove the time element, leaving only the date if you can help please?
 
Upvote 0

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Rick - got it to extract what I need but I need to remove the time element, leaving only the date if you can help please?

Make the change I show in red below (it will make the function retrieve the first "word" instead of the all the text after the colon)...

Code:
Function IndexWords(S As String) As String
  Dim Words() As String
  Words = Split(S, "Claim created on: ", 2)
  If UBound(Words) = 1 Then IndexWords = [COLOR=#FF0000][B]Split([/B][/COLOR]Application.Trim(Split(Words(1), vbLf)(0))[COLOR=#FF0000][B])(0)[/B][/COLOR]
End Function
 
Upvote 0
OK, new issues to deal with now - I want to test if the cell M2 contains just text, i.e.

or text and numbers, i.e.

A simple Msgbox advising which will suffice if anyone can assist?
Try this code snippet in your own code...
Code:
If Len(Range("M2")) = 0 Then
  MsgBox "Cell M2 is empty."
ElseIf Not Range("M2").Value Like "*[!0-9]*" Then
  MsgBox "Cell M2 consists of digits only."
ElseIf Range("M2").Value Like "*#*" Then
  MsgBox "Cell M2 consist of a mixture of text and digits."
Else
  MsgBox "Cell M2 has no digits in it at all."
End If
 
Upvote 0

Forum statistics

Threads
1,216,022
Messages
6,128,326
Members
449,441
Latest member
khankins

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