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
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
JoeMo,

Thanks for looking.
I have a different variation. But I was able to solve it.
Below is what I'm looking at

Code:
c.165C>C/T; p.S55S
c.1212A>A/G; p.V404V
c.3199 G>G/A; p.A1067T
c.4914T>T/A; p.R1638R
c.639T>C; p.D213D''''' I have this one solved using 2 solvers code

Should be
Code:
You will note that the fist character after the "/" is just before the ">"
The rest of the string is deleted.
c.165C>T
c.1212A>G
c.3199 G>A
c.4914T>A
c.639T>C'''Already have code for this
 
Upvote 0
I see your example, but can you just explain the logic?

c.2339A>A/C; p.N780T should become c.2339A>C because ... why?

Does the same rule apply to all strings?
 
Upvote 0
shg,

The string is for medical coding.
As for why I'm not sure about the logic. I'm trying to help a friend.
The only other variation to this "c.639T>C; p.D213D".
In this case you do not see the "/". so this code will be "c.639T>C".
You will note I dropped everything after and including the ";".
 
Upvote 0
I"d say

Code:
sub M_snb()
   msgbox F_snb("c.639T>C; p.D213D")
end sub

function F_snb(c00)
  f_snb=split(split(c00,";")(0),"/")(0)
function end
 
Last edited:
Upvote 0
Here is a macro that does what I think you want...
Code:
Sub ParseMedicalCodes()
  With Range("A1", Cells(Rows.Count, "A").End(xlUp))
    .Copy .Offset(, 1)
    .Offset(, 1).Replace ";*", "", xlPart
    .Offset(, 1).Replace ">*/", ">", xlPart
  End With
End Sub
 
Upvote 0
Hi,

Thanks to snb, Rick and Shg who looked at and helped me. The following is the code that I used.
Thanks to JoeMoe
Code:
Sub Refseq()
Dim Mval As String
Dim i As Long
Dim lrow As Long
Sheets("Sheet2").Activate
lrow = Sheets("Sheet2").Range("A65536").End(xlUp).Row
For i = 2 To lrow
    Range("G" & i) = Range("F" & i) & ":" & CSPLIT(Range("B" & i))
Next
End Sub

Function CSPLIT(strPassed As String) As String

    Dim str, strP As String
    strP = Split(strPassed, ";")(0)
    str = Split(strP, ">")(0) & ">"
    If InStr(1, Split(strPassed, ";")(0), "/") Then
        str = str & Split(Split(strPassed, ";")(0), "/")(1)
    Else
        str = str & Right(Split(strPassed, ";")(0), 1)
    End If
    CSPLIT = str
    
End Function
 
Last edited:
Upvote 0

Forum statistics

Threads
1,217,911
Messages
6,139,361
Members
450,199
Latest member
trafficmonster

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