Unconcatenate a column

NTownend

New Member
Joined
Jun 29, 2018
Messages
18
Office Version
  1. 365
Platform
  1. Windows
SOP57307145_1_1
SOP57307145_1_1
SOP57307145_2_1
SOP57307145_2_1
SOP57307145_2_2
SOP57307145_2_2
SOP57307152_1_1
SOP57307152_1_1
SOP57307152_2_1
SOP57307152_2_1


i have a multiple lines in a column and i want to separate these out, so in the example above i want to get rid of the first 3 characters "SOP" and then separate the next 3 sets of data into 3 columns so i would get
5730714511
5730714511


with the conditions that all three columns could have a different total number of characters in each string i.e

SOP5730714_12_5
SOP573071456_1_15


and so on. text to columns is not workable as i want to automate 1000's of lines
cheers
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hi
Try
VBA Code:
Sub test()
    Dim a, b, x
    Dim i&
    a = Cells(2, 1).Resize(Cells(Rows.Count, 1).End(xlUp).Row - 1)
    ReDim b(1 To UBound(a))
    For i = 1 To UBound(a)
        x = Split(a(i, 1), "_")
        x(0) = Mid(x(0), 4, 255)
        b(i) = x
    Next
    Cells(2, 5).Resize(UBound(b), 3) = Application.Index(b, 0, 0)
End Sub
Or
VBA Code:
Sub test()
    Dim a, b, x
    Dim i&
    a = Cells(2, 1).Resize(Cells(Rows.Count, 1).End(xlUp).Row - 1)
    ReDim b(1 To UBound(a))
    For i = 1 To UBound(a)
    b(i) = Split(Mid(a(i, 1), 4, 255), "_")
    Next
    Cells(2, 5).Resize(UBound(b), 3) = Application.Index(b, 0, 0)
End Sub
 
Upvote 0
Quick and dirty
find and replace P with _ the use Text to columns option
1663141924127.png

1663141961509.png

Book1
CDE
25730714511
35730714511
45730714521
55730714521
65730714522
75730714522
85730715211
95730715211
105730715221
115730715221
12573071456115
Sheet2
 
Upvote 0
Upvote 0
Hi
Try
VBA Code:
Sub test()
    Dim a, b, x
    Dim i&
    a = Cells(2, 1).Resize(Cells(Rows.Count, 1).End(xlUp).Row - 1)
    ReDim b(1 To UBound(a))
    For i = 1 To UBound(a)
        x = Split(a(i, 1), "_")
        x(0) = Mid(x(0), 4, 255)
        b(i) = x
    Next
    Cells(2, 5).Resize(UBound(b), 3) = Application.Index(b, 0, 0)
End Sub
Or
VBA Code:
Sub test()
    Dim a, b, x
    Dim i&
    a = Cells(2, 1).Resize(Cells(Rows.Count, 1).End(xlUp).Row - 1)
    ReDim b(1 To UBound(a))
    For i = 1 To UBound(a)
    b(i) = Split(Mid(a(i, 1), 4, 255), "_")
    Next
    Cells(2, 5).Resize(UBound(b), 3) = Application.Index(b, 0, 0)
End Sub
I will give it a go and let you know thanks for prompt reply
 
Upvote 0
Quick and dirty
find and replace P with _ the use Text to columns option
View attachment 73881
View attachment 73882
Book1
CDE
25730714511
35730714511
45730714521
55730714521
65730714522
75730714522
85730715211
95730715211
105730715221
115730715221
12573071456115
Sheet2
Many thanks for prompt reply it works like you say quick and dirty but i want to automate the process and keep orginal data
 
Upvote 0
Maybe TextSplit:
Book1
ABCD
1SOP57307145_1_15730714511
2SOP57307145_1_15730714511
3SOP57307145_2_15730714521
4SOP57307145_2_15730714521
5SOP57307145_2_25730714522
6SOP57307145_2_25730714522
7SOP57307152_1_15730715211
8SOP57307152_1_15730715211
9SOP57307152_2_15730715221
10SOP57307152_2_15730715221
11SOP5730714_12_55730714125
12SOP573071456_1_15573071456115
Sheet1
Cell Formulas
RangeFormula
B1:D12B1=VALUE(TEXTSPLIT(SUBSTITUTE(A1,"SOP",""),"_"))
Dynamic array formulas.
great thanks for prompt reply, its workable as it keeps orginal data, i have an added problem for this which will follow, shortly .
 
Upvote 0
Hi there

Can try following formula approach as well...

Book1
ABCDE
1SOP57307145_1_15730714511
2SOP57307145_1_15730714511
3SOP57307145_2_15730714521
4SOP57307145_2_15730714521
5SOP57307145_2_25730714522
6SOP57307145_2_25730714522
7SOP57307152_1_15730715211
8SOP57307152_1_15730715211
9SOP57307152_2_15730715221
10SOP57307152_2_15730715221
Sheet2
Cell Formulas
RangeFormula
C1:E10C1=TEXTSPLIT(RIGHT(A1,LEN(A1)-3),"_",", ")
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,215,453
Messages
6,124,930
Members
449,195
Latest member
Stevenciu

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