Transform and tabulate rows of data in specified format

naveenraja16

New Member
Joined
Mar 3, 2016
Messages
10
I am wanted to simplify the task of transforming 1000's of data in rows into a table with specified column headings. I do manual copy paste of data which is tedious.
glm
1PT-550020135
2PT-550020135
3AIT-98932-200150
4FT-98140050
1LT-360010100
2FQIT-3600307000
3LT-372010110
1LT-390010110
2LT-410050100
3LT-380020100
4AIT-37705020
5AIT-395100100

<colgroup><col><col><col><col></colgroup><tbody>
</tbody>

g1l1m1g2l2 m2g3 l3m3g4l4m4g5 l5m5
PT-550020135PT-550020135AIT-98932-200150FT-98140050
LT-360010100FQIT-3600307000LT-372010110
LT-390010110LT-410050100LT-380020100AIT-37705020AIT-395100100

<colgroup><col width="64" span="15" style="width:48pt"> </colgroup><tbody>
</tbody>

with reference to the sample data available in the attached image , The data available in the bounded table on the left has to be tabulated under the headings g1 to m5 respectively. The bounded data with a thick border represents one set . That has to tabulated in the first row. Similarly the second set has to be populated in second row. The sets can be differentiated by referring the numbering of rows . every set begins with number 1 .

Can this forum help me in doing this task through a vba code.
 
Last edited:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Try this code for Results on sheet2 Starting "A1"
Code:
[COLOR="Navy"]Sub[/COLOR] MG15Jul38
[COLOR="Navy"]Dim[/COLOR] Ray [COLOR="Navy"]As[/COLOR] Variant, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] St [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer,[/COLOR] Col [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
Ray = Range("A1").CurrentRegion.Resize(, 4)
ReDim nray(1 To UBound(Ray, 1), 1 To 15)
c = 1
[COLOR="Navy"]For[/COLOR] n = 2 To UBound(Ray, 1)
    [COLOR="Navy"]If[/COLOR] Ray(n, 1) = 1 [COLOR="Navy"]Then[/COLOR]
        c = c + 1: Col = 0
    [COLOR="Navy"]End[/COLOR] If
     [COLOR="Navy"]For[/COLOR] Ac = 2 To 4
       Col = Col + 1
       nray(1, Col) = Ray(1, Ac) & Ray(n, 1)
       nray(c, Col) = Ray(n, Ac)
    [COLOR="Navy"]Next[/COLOR] Ac
[COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]With[/COLOR] Sheets("Sheet2").Range("A1").Resize(c, 15)
    .Value = nray
    .Borders.Weight = 2
    .Columns.AutoFit
 [COLOR="Navy"]End[/COLOR] [COLOR="Navy"]With[/COLOR]
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]

Code Based on data as below in Active sheet:-

ABCD
1 glm
21PT-550020135
32PT-550020135
43AIT-98932-200150
54FT-98140050
61LT-360010100
72FQIT-3600307000
83LT-372010110
91LT-390010110
102LT-410050100
113LT-380020100
124AIT-37705020
135AIT-
39510
0100
<colgroup><col width="62" style="width: 46pt;" span="5"> <tbody> </tbody>
 
Upvote 0

Forum statistics

Threads
1,214,645
Messages
6,120,711
Members
448,984
Latest member
foxpro

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