Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default VBA: Sorting arrays in hierarchichal data structu Help!!!

Help! i have spent many hours poring over this so i hope somebody out
there has some ideas:

I have some data which kind of looks like the following in it's
simplest form:

LEVEL ID INSTRUMENT DEVIATION
1 0 Entry Structure 100
2 0 Beverages 20
3 1 Allied Domecq 8
3 2 Diageo 2
3 3 Scottish Newcastle 10
2 0 Mining 30
3 4 GOC 10
3 5 Rio Tinto 20


The data is stored in an array let's say in this example: varData(8,
4)
(8 rows, 4 columns)

I am trying to develop an algorithm to sort the data by DEVIATION in
hierarchical order - that is, sort everything at level 1 first, then
2, then 3.

Once sorted the data will look like this:

1 0 Entry Structure 100
2 0 Mining 30
3 5 Rio Tinto 20
3 4 GOC 10
2 0 Beverages 20
3 3 Scottish Newcastle 10
3 1 Allied Domecq 8
3 2 Diageo 2

It looks simple enough but once you start working on it you end up
going around in circles and then get confused/frustrated/give up/go
mad. I'm working with much more levels than this and it's not nice.

Anyone help? I'm slowly going insane............
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Sorting arrays in hierarchichal data structu Help!!!

If I sort on Deviation within Level, then all the levels should be together
like this:

LEVEL ID INSTRUMENTATION DEVIATION DUM
1 0 Entry Structure 100 1
2 0 Mining 30 6
2 0 Beverages 20 2
3 5 Rio Tinto 20 8
3 3 Scottish Newcastle 10 5
3 4 GOC 10 7
3 1 Allied Domecq 8 3
3 2 Diageo 2 4


but you don't show that as your result

You have level 2 Beverages mixed in with Leve 3. Could you state a little
more clearly what you want to do.

--
Regards,
Tom Ogilvy

"Karen Lee" wrote in message
om...
Help! i have spent many hours poring over this so i hope somebody out
there has some ideas:

I have some data which kind of looks like the following in it's
simplest form:

LEVEL ID INSTRUMENT DEVIATION
1 0 Entry Structure 100
2 0 Beverages 20
3 1 Allied Domecq 8
3 2 Diageo 2
3 3 Scottish Newcastle 10
2 0 Mining 30
3 4 GOC 10
3 5 Rio Tinto 20


The data is stored in an array let's say in this example: varData(8,
4)
(8 rows, 4 columns)

I am trying to develop an algorithm to sort the data by DEVIATION in
hierarchical order - that is, sort everything at level 1 first, then
2, then 3.

Once sorted the data will look like this:

1 0 Entry Structure 100
2 0 Mining 30
3 5 Rio Tinto 20
3 4 GOC 10
2 0 Beverages 20
3 3 Scottish Newcastle 10
3 1 Allied Domecq 8
3 2 Diageo 2

It looks simple enough but once you start working on it you end up
going around in circles and then get confused/frustrated/give up/go
mad. I'm working with much more levels than this and it's not nice.

Anyone help? I'm slowly going insane............



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sorting arrays in hierarchichal data structu Help!!!

We are not sorting solely by deviation. Rows are related like a 'tree'
structure and level hierarchy from the original data must be maintained.

It might help if I show the data like this:

1 0 Entry Structure 100
2 0 Beverages 20
3 1 Allied Domecq 8
3 2 Diageo 2
3 3 Scottish Newcastle 10
2 0 Mining 30
3 4 GOC 10
3 5 Rio Tinto 20

- Level 1 acts as the root and is the umbrella for everything - it is
always at the top.

- At level 2 Beverages and Mining act as group headers for everything
underneath (which are the level 3s). So instruments 1, 2 and 3 must
always be under Beverages and instruments 4 and 5 under Mining.

- The level 2s are sorted first, including everything underneath:
1 0 Entry Structure 100
2 0 Mining 30
3 4 GOC 10
3 5 Rio Tinto 20
2 0 Beverages 20
3 1 Allied Domecq 8
3 2 Diageo 2
3 3 Scottish Newcastle 10

- Then we sort the level 3 instruments to give the finished product:

1 0 Entry Structure 100
2 0 Mining 30
3 5 Rio Tinto 20
3 4 GOC 10
2 0 Beverages 20
3 3 Scottish Newcastle 10
3 1 Allied Domecq 8
3 2 Diageo 2



Rgds,

K











*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
Postcode structure for data validation JohnG Excel Discussion (Misc queries) 3 October 7th 09 06:14 PM
Does structure of data affect speed of vlookup? Brotherharry Excel Worksheet Functions 6 March 7th 09 05:20 PM
how do I put the symbol of structure above data Expedito Excel Discussion (Misc queries) 0 June 15th 08 03:17 AM
how do I put the symbol of structure above data Expedito Excel Discussion (Misc queries) 0 June 15th 08 03:17 AM
data structure and my problem samantha Excel Worksheet Functions 2 April 11th 05 02:38 PM


All times are GMT +1. The time now is 01:45 PM.

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

About Us

"It's about Microsoft Excel"