Text Extraction

DT3202

New Member
Joined
Oct 30, 2014
Messages
7
Office Version
  1. 2016
Platform
  1. Windows
Good Morning Everyone,
I have an issue where the clinical team is downloading csv files and manually copy/pasting summaries. The data from the system they use comes with text, symbols, and numbers in the cell. I only need the text and am trying to figure out how to extract it into another cell with a formula. Here is an example of the data:

1576168267437.png
 
Here's a UDF I cooked up:

Code:
Function GetString(c As Range) As String
 Dim GS As String
 GetString = ""
 GS = c.Value & ";"
While 0 <> Len(GS)
 GetString = GetString & Mid(Left(GS, WorksheetFunction.Find(";", GS) - 1), WorksheetFunction.Find("|", GS) + 1, Len(GS)) & " "
 GS = Right(GS, Len(GS) - WorksheetFunction.Find(";", GS))
Wend
GetString = Left(GetString, Len(GetString) - 1)
End Function
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Use this

Book1
AB
135af8334-67ba-4020-b833-22a2b07408a3|Gown;0ffdc59f-6402-4a66-b3ba-cc02bef9ed13|Gloves;5f7af1d3-689d-48d4-b9c4-50aa30436003|Face shield;20c6ffd9-0dd1-4663-b99e-3860f493df6c|Hair covering;dd949532-1bbf-4d48-956d-4cde929003b1|Shoe coversGown Gloves Face shield Hair covering Shoe covers
Hoja2
Cell Formulas
RangeFormula
B1B1=ExtractText(A1)



VBA Code:
Function ExtractText(c As Range) As String
  Dim cad As String, e As Variant
  For Each e In Split(c.Value & ";", ";")
    cad = cad & Mid(e, InStr(1, e, "|") + 1) & " "
  Next
  ExtractText = WorksheetFunction.Trim(cad)
End Function
 
Upvote 0
Here's a UDF I cooked up:

Code:
Function GetString(c As Range) As String
Dim GS As String
GetString = ""
GS = c.Value & ";"
While 0 <> Len(GS)
GetString = GetString & Mid(Left(GS, WorksheetFunction.Find(";", GS) - 1), WorksheetFunction.Find("|", GS) + 1, Len(GS)) & " "
GS = Right(GS, Len(GS) - WorksheetFunction.Find(";", GS))
Wend
GetString = Left(GetString, Len(GetString) - 1)
End Function

thanks! This did the trick!

1576180771345.png
 
Upvote 0
Use this

Book1
AB
135af8334-67ba-4020-b833-22a2b07408a3|Gown;0ffdc59f-6402-4a66-b3ba-cc02bef9ed13|Gloves;5f7af1d3-689d-48d4-b9c4-50aa30436003|Face shield;20c6ffd9-0dd1-4663-b99e-3860f493df6c|Hair covering;dd949532-1bbf-4d48-956d-4cde929003b1|Shoe coversGown Gloves Face shield Hair covering Shoe covers
Hoja2
Cell Formulas
RangeFormula
B1B1=ExtractText(A1)



VBA Code:
Function ExtractText(c As Range) As String
  Dim cad As String, e As Variant
  For Each e In Split(c.Value & ";", ";")
    cad = cad & Mid(e, InStr(1, e, "|") + 1) & " "
  Next
  ExtractText = WorksheetFunction.Trim(cad)
End Function

This works as well. Thanks for the help!
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,525
Members
448,969
Latest member
mirek8991

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