Need help parsing text from a cell please

rhaas128

Board Regular
Joined
Jul 5, 2013
Messages
84
I have thousands of rows in a sheet and one specific column I need to parse text from. If you know a better way to perform this task than what I am about to explain, please feel free to share :) Basically, I want to look for specific text within the column, and put that text and a bit of text after it into a new cell. See below for an example between the asterisks:

************************************
Request: NeededAccess
Access Number : 01
Access Name : ANAME


Business Justification: New hire for AKFE.
************************************

I want to look for the Access Name. I don't NEED "Access Name", just the name after the colon. However, I can accept this entire line if I must. The catch is, this line may not always exist, or may not be the same line number in each cell within the column. Is this feat possible?

Thanks for any and all help in advance and hopefully this task is clear.
 
Thank you both. Both of these options work beautifully!
Just pointing out that you had three solution responses to your question... I think you may have overlooked the formula solution that konttaruan gave you in Message #4 which also works.
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Here is another macro that you can consider...
Code:
[TABLE]
<tbody>[TR]
[TD]Sub GetAccessName()
  Dim R As Long, Data As Variant
  Data = Range("A2", Cells(Rows.Count, "A").End(xlUp))
  For R = 1 To UBound(Data)
    If InStr(Data(R, 1), "Access Name : ") Then
      Data(R, 1) = Split(Split(Data(R, 1), "Access Name : ", , vbTextCompare)(1), vbLf)(0)
    Else
      Data(R, 1) = "No Match"
    End If
  Next
  Range("B2").Resize(UBound(Data)) = Data
End Sub[/TD]
[/TR]
</tbody>[/TABLE]
Question on this one, let's say the Access Name is actually (with the following quotes and period) "Pharmacy Tech". Right now I have managed to ignore the first " by splitting after it. However, the last ". will still be included as it is part of the line. Is there a way to ignore that portion of the line?
 
Upvote 0
Question on this one, let's say the Access Name is actually (with the following quotes and period) "Pharmacy Tech". Right now I have managed to ignore the first " by splitting after it. However, the last ". will still be included as it is part of the line. Is there a way to ignore that portion of the line?
See if this modification to my code does what you want...
Code:
Sub GetAccessName()
  Dim R As Long, Data As Variant
  Data = Range("A2", Cells(Rows.Count, "A").End(xlUp))
  For R = 1 To UBound(Data)
    If InStr(Data(R, 1), "Access Name : ") Then
      Data(R, 1) = Replace(Replace(Split(Split(Data(R, 1), "Access Name : ", , _
                   vbTextCompare)(1), vbLf)(0), """.", ""), """", "")
    Else
      Data(R, 1) = "No Match"
    End If
  Next
  Range("B2").Resize(UBound(Data)) = Data
End Sub
 
Upvote 0
See if this modification to my code does what you want...
Code:
Sub GetAccessName()
  Dim R As Long, Data As Variant
  Data = Range("A2", Cells(Rows.Count, "A").End(xlUp))
  For R = 1 To UBound(Data)
    If InStr(Data(R, 1), "Access Name : ") Then
      Data(R, 1) = Replace(Replace(Split(Split(Data(R, 1), "Access Name : ", , _
                   vbTextCompare)(1), vbLf)(0), """.", ""), """", "")
    Else
      Data(R, 1) = "No Match"
    End If
  Next
  Range("B2").Resize(UBound(Data)) = Data
End Sub
This works perfect. Thanks again!
 
Upvote 0

Forum statistics

Threads
1,215,339
Messages
6,124,362
Members
449,155
Latest member
ravioli44

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