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

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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