Split Sting baised on 2 characters

CharlesH

Active Member
Joined
Apr 23, 2005
Messages
467
Hi,

I'm in the need for some help.
I can usually find or come up with an answer. But this one has me stumped.
What I'm looking for is a code that will split this


Code:
c.2339A>A/C; p.N780T

To

Code:
c.2339A>C

Any help would be appreciated.

I also have this posted on:

Split string
 
I'd prefer:

Code:
Function F_snb(c00)
    If InStr(c00, "/") Then
        F_snb = Join(Filter(Split(Replace(Replace(c00, ";", "/;"), ">", "/;"), "/"), ";", False), ">")
    Else
        F_snb = Split(c00, ";")(0)
    End If
End Function
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Code:
...
...
For i = 2 To lrow
    Range("G" & i) = Range("F" & i) & ":" & CSPLIT(Range("B" & i))
Next
End Sub
...
...
If you had told us what your ultimate goal was instead of only telling us half the problem, we could have designed a complete solution for you initially. The following code uses the concept I used in Message #9, only modified to do what you actually want to do. This code should be faster than what you settled on as it uses no loops and does not repeatedly call an outside function over and over again.
Code:
Sub ParseMedicalCodes()
  Dim LastRow As Long
  Sheets("Sheet2").Activate
  LastRow = Cells(Rows.Count, "B").End(xlUp).Row
  With Range("G2:G" & LastRow)
    .Value = Evaluate(Replace("IF(LEN(B2:B#),F2:F#&"":""&B2:B#,"""")", "#", LastRow))
    .Replace ";*", "", xlPart
    .Replace ">*/", ">", xlPart
  End With
End Sub
 
Upvote 0
Rick, snb

Thanks again for the coding that was provided.
Prior to posting I tried to find an answer to my problem.
I only found a solution for "c.1209G>T; p.P403P". But , the code I came up with did not address the issue for the following string.
"c.159C>C/G; p.A53A". That's why I posted for help.
My primary concern was how to split the string to the desired result as all of you provided.
I believe that was why I did not provide the over all concept.

Rick, yes your code is faster and shorter I'll adapt it.
I cannot express all of My thanks to those who helped.
With the help I learned a lot.
 
Upvote 0
But , the code I came up with did not address the issue for the following string.
"c.159C>C/G; p.A53A". That's why I posted for help.
My primary concern was how to split the string to the desired result as all of you provided.
I believe that was why I did not provide the over all concept.
I understand that, but what I am suggesting for future questions is to maybe explain what you plan to do with the answer to the question you ask, just in case someone has an idea for a better approach to your overall need than the one you settled on. More than likely, you will simply get the answer to the question you ask, but every now and then, you may get a more efficient solution to your overall need instead. In any event, the extra information about what you are ultimately trying to do will help in fully understanding the question you actually are seeking help for anyway, so the effort to provide it would not be wasted.
 
Upvote 0

Forum statistics

Threads
1,217,989
Messages
6,139,815
Members
450,239
Latest member
conna_1996

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