Compiling a list of observations into a table

mfxuus

New Member
Joined
Oct 18, 2013
Messages
3
Hey All,

Here is a sample observation, the data is basically thousands of this kind of data listed in 2 columns.

$$
AN
0588470
ST
Academia Economic Papers
IS
1018-161X
CI
29 3
PD
September 2001
DJ
2001
AU
Rau, Hsiu-Hua
AI
R
AU
Lin, Hsiou-Wei William
AI
L
AU
Li, Ming-Yuan Leon
AI
L
TI
Examining Taiwan's Business Cycle via Two-Period MS Models. (In Chinese. With English summary.)
DE
Business Fluctuations; Cycles_(E320)
DE
General Aggregative Models: General_(E100)
DE
Macroeconomic Analyses of Economic Development_(O110)
KW
Business Cycles; Cycle
AF
National Cheng Chi U
AF
National Taiwan U
AF
National Chi Nan U

<tbody>
</tbody>

And I want to put them in to format like this, with each observation occupying one row:
ANSTISCIPDDJAU_1AI_1AU_2AI_2...TIDE_1DE_2DE_3..KW_1KW_2..AF_1AF_2AF_3..AF_n

<tbody>
</tbody>




Basically the original format is a long list of data, and I need to put each observation into a row, while putting the values into the correct columns. The tricky point is that for the "AU","AI","DE","KW","AF", the numbers vary for different observations. Some observations have just one each, but some have 2,or 3 or more, so in the list, each observation takes up a different length of range. For those that have multiple "AU"'s, the table version would need to have "AU_1", "AU_2"....

I have an idea about how to achieve this, but I have little experience with VBA, so I don't even know how to get started. Can I say something like: (not in VBA codes)

i=1, j=0
For i<=100000:
Look at Ai,
if Ai="$$":
j=j+1
i=i+1

if Ai="AN", then let Aj(in sheet 2)= Bi(in sheet 1)
i=i+1
if Ai="ST", then let Bj (in sheet 2)=Bi(in sheet 1)
i=i+1
...
....
if Ai="AU", if Gj = "", Gj=Bi
if Gj !="", if Ij="", Ij=Bi
if Ij != "", if Kj="", Kj=Bi.....
i=i+1
if Ai="AI", .....
and so on,,

you get the idea, I know this is probably the most inefficient way to do it, but even so I don't know how to write out the code.. Any help would be appreciated!!!
Thanks!!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,215,482
Messages
6,125,060
Members
449,206
Latest member
Healthydogs

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