Transpose Data into multiple Columns

syar

Board Regular
Joined
Dec 5, 2008
Messages
97
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
2.xlsx
A
643 abcdf
716-6789
80316-xxxxxx
9Criminal
1044 thisishshs
1118-1141
120315-xxxxx
13Criminal
1445
15anonymos
1617-8262
170314-xxxx
18Criminal
1946 mmmmmm
2016-6717
210317-xxxxx
22Criminal
2317 asdf
2416-6929
250334 -xxxxxx
26Civil
Sheet2


I have inserted data from picture to excel sheet and it copied in one column A6: A276. Now i need to convert/transpose this data into 04 columns "
S.No - Name - BC ID - Contact No -- Specialty"
the converted data is in sequence but there is a problem that some data had S.no combined with name like "43 abcdf" . how to move or transpose this data into relevant columns. i tried columns to text but not succeed.

your help in this appreciated.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Like this ??
but it has a drawback, which is that there can be no space in every text except in the number & name text.

Excel Formula:
=LET(a,IFERROR(TEXTSPLIT(TEXTJOIN("|",,A1:A21)," ","|",TRUE),""),b,TOCOL(a),c,FILTER(b,b<>""),WRAPROWS(c,5))


1716520967701.png

but it has a drawback, which is that there cannot be spaces in each text except in the number & name texts
 
Upvote 0
Thanks for your response.
there is two problem i am encountering.
1. if "Name" had a second name like " John Doe" it split it into separate columns
2. I am applying the formula on "A1:A320", it split contact number with "-" in separate columns

regards
 
Upvote 0
Specialty given in data is Criminal and Civil. Are you having more than these 2. Pl give the full list of all specialties used in file.
 
Upvote 0
@sayar given what you have stated then you could try the below.
However if there is inconsistency in the structure of your individual data elements, especially regarding spaces, you will always have potential for error.
eg Your original post has a space before the - in the last contact number. Hopefully that was a typo on your part and not typical of the live data.

Testing Formula Update.xlsm
ABCDEFG
143 Jon Alfred DoeS No.NameBC IDContactSpeciality
216-678943Jon Alfred Doe16-67890316-xxxxxxCriminal
30316-xxxxxx44 this ish shs18-11410315-xxxxxCriminal
4Criminal45anonymos17-82620314-xxxxCriminal
544 this ish shs46mmmmmm16-67170317-xxxxxCriminal
618-114117asdf16-69290334-xxxxxxCivil
70315-xxxxx
8Criminal
945
10anonymos
1117-8262
120314-xxxx
13Criminal
1446 mmmmmm
1516-6717
160317-xxxxx
17Criminal
1817 asdf
1916-6929
200334-xxxxxx
21Civil
22
Sheet2
Cell Formulas
RangeFormula
C2:G6C2=LET(a,IFERROR(TEXTSPLIT(TEXTJOIN("|",,SUBSTITUTE(A1:A350," ","|",1)),"|"),""),b,TOCOL(a),c,FILTER(b,b<>""),WRAPROWS(c,5))
Dynamic array formulas.

HTH
 
Upvote 0
Solution
Try this VBA code. Result is at C6.
VBA Code:
Sub ArrangeData()
Dim A, hdr, M
Dim T&, Ta&, X&
Dim Rng As Range
A = Range("A6:A36")
Set Rng = Range("C6")      'result range, can be changed
hdr = Array("S.No", "Name", "BC ID", "Contact No", "Specialty")

With CreateObject("Scripting.dictionary")
For T = 1 To UBound(A, 1)
If IsNumeric(A(T, 1)) Then
X = 4
.Item(T) = Array(A(T, 1), A(T + 1, 1), A(T + 2, 1), A(T + 3, 1), A(T + 4, 1))
Else
X = 3
M = Split(A(T, 1), " ")
.Item(T) = Array(M(0) + 0, M(1), A(T + 1, 1), A(T + 2, 1), A(T + 3, 1))
End If
T = T + X
Next T
Rng.CurrentRegion.Clear
Rng.Resize(1, 5) = hdr
Rng.Offset(1, 0).Resize(.Count, 5) = Application.Index(.items, 0, 0)

End With
End Sub
1716543040458.png
 
Upvote 0
@Snakehips. Yes, you are write the typo was on my part, and there is some inconsistency in the data so i adjust it manually the formula work fine. Thanks for your support
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,847
Members
452,361
Latest member
d3ad3y3

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