Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Need help parsing column data - new to Excel

I have an old DB system from which I've exported data out to several
..ASC text files. I need to massage it to use it in Excel. The
original DB is proprietary, so I can't get to its tables with the
normal tools. All I can do is "export" the data in a text format, and
I have no control over that format.

Each record in the original DB has 8 fields, and there are about 1000
records. The data exports as a single field column, as opposed to
delimited, so I've got about 8000 rows, each row containing 1 field.
The first row is indexed (I guess for fields 1 through 8) as "01", and
then data. Row 2 is "02" & data, Row 3 is "03" & data; so forth and so
on, with row 9 starting over at "01". The exported data looks as
follows:

01XXXXX
02VCVFRD
03LOIKJH
04JYTRFDE
05LKIIUJH
0698jujg43
07jh765rfde
08KJH&^%$fd
01HG54433ee
02IKJU*&^%677
etc., etc.

I need to parse the data horizontally into 9 columns to look like a
normal table, with each field in its own cell (the first column would
be my index). Something like this:

1001 XXXXX VCVFRD LOIKJH JYTRFDE LKIIUJH etc.....
1002 HG54433ee IKJU*&^%677 etc.....

One kicker: Sometimes, all 8 fields are not there, so you will have a
section of the original column where it goes 01, 02, 03, 04, 05, and
then back to 01 again, so you just can't say put the first item in A1,
the second in A2, etc. You have to check that "index".

I have to do this with 20 different "tables". If you can get me
through this one, I can probably extrapolate the concept to the others.

I've done a bit with Excel, so I'm not helpless, but I'm not sure how
to go about this.

Any help would be appreciated.

Latenite

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Need help parsing column data - new to Excel


Martin Fishlock wrote:
I think you will find this will do the job. copy it into a workbook and make
the download active and run it it will make a new sheet.

Option Explicit

Sub convertdb()
Dim wsS As Worksheet
Dim wsD As Worksheet
Dim lRowD As Long
Dim lastcol As Integer
Dim col As Integer
Dim rCell As Range

lastcol = 9999
lRowD = 0
Set wsS = ActiveSheet
Set wsD = Worksheets.Add
For Each rCell In wsS.UsedRange
col = Left(rCell.Value, 2) ' current column
If col < lastcol Then ' check if new row col < lsst col
lRowD = lRowD + 1 ' new row
End If
lastcol = col 'record the column for next time
wsD.Cells(lRowD, 1) = lRowD + 1000 ' record no (+1000)
wsD.Cells(lRowD, col + 1) = _
Right(rCell.Value, Len(rCell.Value) - 2) ' data
Next rCell
End Sub

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Latenite" wrote:

I have an old DB system from which I've exported data out to several
..ASC text files. I need to massage it to use it in Excel. The
original DB is proprietary, so I can't get to its tables with the
normal tools. All I can do is "export" the data in a text format, and
I have no control over that format.

Each record in the original DB has 8 fields, and there are about 1000
records. The data exports as a single field column, as opposed to
delimited, so I've got about 8000 rows, each row containing 1 field.
The first row is indexed (I guess for fields 1 through 8) as "01", and
then data. Row 2 is "02" & data, Row 3 is "03" & data; so forth and so
on, with row 9 starting over at "01". The exported data looks as
follows:

01XXXXX
02VCVFRD
03LOIKJH
04JYTRFDE
05LKIIUJH
0698jujg43
07jh765rfde
08KJH&^%$fd
01HG54433ee
02IKJU*&^%677
etc., etc.

I need to parse the data horizontally into 9 columns to look like a
normal table, with each field in its own cell (the first column would
be my index). Something like this:

1001 XXXXX VCVFRD LOIKJH JYTRFDE LKIIUJH etc.....
1002 HG54433ee IKJU*&^%677 etc.....

One kicker: Sometimes, all 8 fields are not there, so you will have a
section of the original column where it goes 01, 02, 03, 04, 05, and
then back to 01 again, so you just can't say put the first item in A1,
the second in A2, etc. You have to check that "index".

I have to do this with 20 different "tables". If you can get me
through this one, I can probably extrapolate the concept to the others.

I've done a bit with Excel, so I'm not helpless, but I'm not sure how
to go about this.

Any help would be appreciated.

Latenite



Martin,

Thank you for the quick reply. I will try it in the morning.

Latenite

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
text parsing/table creation from single column data cruiser Excel Discussion (Misc queries) 1 October 24th 07 12:19 PM
Excel 2K and parsing data Ed Excel Worksheet Functions 2 September 4th 07 05:42 PM
Helping Parsing Excel Data [email protected] Excel Programming 2 December 8th 06 02:39 AM
parsing data into Excel [email protected] Excel Discussion (Misc queries) 2 July 17th 06 05:44 PM
Parsing Data From HTML Source into Excel using VBA Peter Dickson Excel Programming 1 July 9th 03 11:00 PM


All times are GMT +1. The time now is 09:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"