Extract last two characters from the middle of a dataset name

markzasz

New Member
Joined
Aug 12, 2015
Messages
29
I have multiple files containing thousands of datasets names and I need to extract the last two characters from the second level of the dataset, below is an example of a files and what I am looking for.

file before:

A B C
Dataset name Volume CUA
[TABLE="width: 0"]
<tbody>[TR]
[TD]PMXGS.MKTCH.LOADLIBC
[/TD]
[TD] CMOCI0
[/TD]
[TD] B325
[/TD]
[/TR]
[TR]
[TD]PMXRA.EXICH.LOADLIBC
[/TD]
[TD] CMOCI0
[/TD]
[TD] B325
[/TD]
[/TR]
[TR]
[TD]PMXRA.PFRCH.LOADLIBC
[/TD]
[TD] CMOCI0
[/TD]
[TD] B325
[/TD]
[/TR]
[TR]
[TD]PMXRA.ZBGCH.LOADLIBC
[/TD]
[TD] CMOCI0
[/TD]
[TD] B325
[/TD]
[/TR]
[TR]
[TD]PMXRA.ZJJCH.LOADLIBC
[/TD]
[TD] CMOCI0
[/TD]
[TD] B325
[/TD]
[/TR]
[TR]
[TD]PMXRS.CONCH.LOADLIBC
[/TD]
[TD] CMOCI0
[/TD]
[TD] B325
[/TD]
[/TR]
</tbody>[/TABLE]


What I want it to look like is this:

A B C D
Dataset name Volume CUA Last two
[TABLE="width: 0"]
<tbody>[TR]
[TD]PMXGS.MKTCH.LOADLIBC
[/TD]
[TD] CMOCI0
[/TD]
[TD] B325
[/TD]
[TD] CH
[/TD]
[/TR]
[TR]
[TD]PMXRA.EXIBZ.LOADLIBC
[/TD]
[TD] CMOCI0
[/TD]
[TD] B325
[/TD]
[TD] BZ
[/TD]
[/TR]
[TR]
[TD]PMXRA.PFR7C.LOADLIBC
[/TD]
[TD] CMOCI0
[/TD]
[TD] B325
[/TD]
[TD] 7C
[/TD]
[/TR]
[TR]
[TD]PMXRA.ZBGCH.LOADLIBC
[/TD]
[TD] CMOCI0
[/TD]
[TD] B325
[/TD]
[TD] CH
[/TD]
[/TR]
[TR]
[TD]PMXRA.ZJJCM.LOADLIBC
[/TD]
[TD] CMOCI0
[/TD]
[TD] B325
[/TD]
[TD] CM
[/TD]
[/TR]
[TR]
[TD]PMXRS.CONDH.LOADLIBC
[/TD]
[TD] CMOCI0
[/TD]
[TD] B325
[/TD]
[TD] DH
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


Mark
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
some VBA
Code:
Sub t()
Dim c As Range, spl As Variant
With ActiveSheet
    For Each c In .Range("A2", .Cells(Rows.Count, 1).End(xlUp))
        spl = Split(c.Value, ".")
        c.Offset(, 3) = Right(spl(1), 2)
    Next
End With
End Sub
 
Upvote 0
Assuming your examples are representative of your actual data, then here is a formula that you can use...

=RIGHT(TRIM(MID(SUBSTITUTE(A2,".",REPT(" ",200)),200,200)),2)
 
Last edited:
Upvote 0
I have multiple files containing thousands of datasets names and I need to extract the last two characters from the second level of the dataset, below is an example of a files and what I am looking for.

file before:

A B C
Dataset name Volume CUA
[TABLE="width: 0"]
<tbody>[TR]
[TD]PMXGS.MKTCH.LOADLIBC[/TD]
[TD] CMOCI0[/TD]
[TD] B325[/TD]
[/TR]
[TR]
[TD]PMXRA.EXICH.LOADLIBC[/TD]
[TD] CMOCI0 [/TD]
[TD] B325[/TD]
[/TR]
[TR]
[TD]PMXRA.PFRCH.LOADLIBC[/TD]
[TD] CMOCI0[/TD]
[TD] B325[/TD]
[/TR]
[TR]
[TD]PMXRA.ZBGCH.LOADLIBC [/TD]
[TD] CMOCI0[/TD]
[TD] B325[/TD]
[/TR]
[TR]
[TD]PMXRA.ZJJCH.LOADLIBC[/TD]
[TD] CMOCI0 [/TD]
[TD] B325[/TD]
[/TR]
[TR]
[TD]PMXRS.CONCH.LOADLIBC[/TD]
[TD] CMOCI0[/TD]
[TD] B325[/TD]
[/TR]
</tbody>[/TABLE]


What I want it to look like is this:

A B C D
Dataset name Volume CUA Last two
[TABLE="width: 0"]
<tbody>[TR]
[TD]PMXGS.MKTCH.LOADLIBC[/TD]
[TD] CMOCI0[/TD]
[TD] B325[/TD]
[TD] CH[/TD]
[/TR]
[TR]
[TD]PMXRA.EXIBZ.LOADLIBC[/TD]
[TD] CMOCI0[/TD]
[TD] B325[/TD]
[TD] BZ[/TD]
[/TR]
[TR]
[TD]PMXRA.PFR7C.LOADLIBC[/TD]
[TD] CMOCI0[/TD]
[TD] B325[/TD]
[TD] 7C[/TD]
[/TR]
[TR]
[TD]PMXRA.ZBGCH.LOADLIBC[/TD]
[TD] CMOCI0[/TD]
[TD] B325[/TD]
[TD] CH[/TD]
[/TR]
[TR]
[TD]PMXRA.ZJJCM.LOADLIBC[/TD]
[TD] CMOCI0[/TD]
[TD] B325[/TD]
[TD] CM[/TD]
[/TR]
[TR]
[TD]PMXRS.CONDH.LOADLIBC[/TD]
[TD] CMOCI0[/TD]
[TD] B325[/TD]
[TD] DH[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
There is a simple forumala for this =MID(A1,10,2)
 
Upvote 0
There is a simple forumala for this =MID(A1,10,2)
Looks like you made a good observation. If, in fact, each of the first two fields are always five characters long, then your simple formula will work fine. However, if the fields can vary in length, then the OP would need the formula I posted in Message #3 instead.
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,307
Members
452,633
Latest member
DougMo

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