Except tasks from sorting (sorting-excepted tasks remain at their relative position)

U

uli

Hello together,

I get the info, to post the problem here - I don't know how to remove
it from microsoft.public.project, where I posted it before. Sorry for
this double-entry...

In microsoft.public.project.developer I found a similar, but not really
to-code-leading theme "sorting a Task Collection".

Imagine a few normal tasks, all the only level 1 (to simplify). We
could use one same text field for the sorting key content so well as
the criteria for non sorting. Let us say, in the non-sorting case the
content is "non sorting", in any other (to sorting) case, the content
is x-beliebig (so you say in German for "arbitrary", "any" and so on)

If you sort all tasks, the sorting order will show all tasks with text
field content "non sorting" together, whatever line (row) these
non-sorting tasks will beginn.

But I will not sort tasks with criteria "non sorting" - I will sort
them not, I will except them from sorting. If the user moves these
non-sorting tasks arbitrary to a certain position (line), these
non-sorting tasks should remain at this position after subsequent
sortings.

Forget details or definition problems like: Is it ecactly enough
defined if one says "non sorting tasks remain at their relative
position". It would be good enough in the first step, if the not sorted
tasks hang approximatly around there old position. We must not define,
if they should appear above ore below or whatever relative position to
any (old or new inserted) sort-allowed task.

Or in othe words: in the first step I would accept however ms-project
will positioning the non-sorted tasks - as long, as ms-project them let
out of sorting.

How in the hell I take out tasks from sorting! - that's all I want. Who
finds the ansatz?

PS: (Please forget the from time to time arising
"Filtering-before-Sorting-Blödsinn". To sort only the filtered part
will lead after refiltering to nothing other than sorting all).

yours Uli from Germany
 
J

Jack Dahlgren

Uli,

I don't understand why you want the unsorted tasks to remain in the same
position. Wouldn't they be completely out of context?

Imagine a file with some tasks

banana1
banana2
apple1
apple2
apple3
apple4
apple5
apple6

The user adds a new task after banana2 so now it looks like:
banana1
banana2
banana3 (no sort)
apple1
apple2
apple3
apple4
apple5
apple6

Now sort the file alphabetically:

apple1
apple2
banana3 (No Sort)
apple3
apple4
apple5
apple6
banana1
banana2

But... let us leave your reason behind. The answer to this is probably to
create an array to work out the sorting and then apply the results of the
sorting to a second text field (or number field etc.). I don't have time to
work out the algorithm right now, but I'd start by doing something like
creating an array with the original position of the task, the data that the
task is going to be sorted on and whether it is to be sorted or not.

read the date into the array on the first pass:
for i= 0 to activeproject.tasks.count -1
set mytask = activeproject.tasks(i+1)
myarray(i,0) = i
myarray(i,1) = mytask.text1
if mytask.text1 = "no sort" then
myarray(i,2) = 1
end if

Then you need to write some code to perform a bubble sort on the array and
SKIP the lines which have a 1 in the sort field. I don't have code for this
available right now, but google for bubble sort and you will find out how it
can be done. Other sorting algorithms may be better, but I'm not an expert
at this.

Finally, read through the array line by line and assign the new values to a
field that you can sort on.

for i = 0 to upperbound(myarray)
activeproject.tasks(i).text20 = i
next i

Then finally use project to sort the tasks according to text20

It sounds a bit complicated, but the array processing should go pretty quick
even on a big file.

Note: NONE OF THIS CODE HAS BEEN TESTED. I am working from memory so the
syntax may be slightly different or I may have made an error in numbering
the array (by default arrays in Project VBA are 0 based. That is the first
position is 0, not 1, so please test it first.

-Jack Dahlgren

@yahoo.de> wrote in message
Hello together,

I get the info, to post the problem here - I don't know how to remove
it from microsoft.public.project, where I posted it before. Sorry for
this double-entry...

In microsoft.public.project.developer I found a similar, but not really
to-code-leading theme "sorting a Task Collection".

Imagine a few normal tasks, all the only level 1 (to simplify). We
could use one same text field for the sorting key content so well as
the criteria for non sorting. Let us say, in the non-sorting case the
content is "non sorting", in any other (to sorting) case, the content
is x-beliebig (so you say in German for "arbitrary", "any" and so on)

If you sort all tasks, the sorting order will show all tasks with text
field content "non sorting" together, whatever line (row) these
non-sorting tasks will beginn.

But I will not sort tasks with criteria "non sorting" - I will sort
them not, I will except them from sorting. If the user moves these
non-sorting tasks arbitrary to a certain position (line), these
non-sorting tasks should remain at this position after subsequent
sortings.

Forget details or definition problems like: Is it ecactly enough
defined if one says "non sorting tasks remain at their relative
position". It would be good enough in the first step, if the not sorted
tasks hang approximatly around there old position. We must not define,
if they should appear above ore below or whatever relative position to
any (old or new inserted) sort-allowed task.

Or in othe words: in the first step I would accept however ms-project
will positioning the non-sorted tasks - as long, as ms-project them let
out of sorting.

How in the hell I take out tasks from sorting! - that's all I want. Who
finds the ansatz?

PS: (Please forget the from time to time arising
"Filtering-before-Sorting-Blödsinn". To sort only the filtered part
will lead after refiltering to nothing other than sorting all).

yours Uli from Germany
 
U

uli

Hello Jack,

thanks and let me time to think about your contribution... I answer in
this regard later.

But - as you asked for some background information - here meanwhile my
reasons for the "some-out-of-sorting-project" and a sample in some
states:

In an existing ms-project sheet with some manual entered tasks (id est
the non-to-sort tasks) a software named CleanQuest inserts a bundle of
tasks. This inserted (or imported) tasks are possesing in a text field
a code like 001 or 222 or 452 and so on. Therefore you can sort and
hold together this inserted tasks. The import of this inserted tasks
begins always at the end of the already existing tasks and they must be
sorted, because their order is unsorted.

To arrange freely some of the inserted/imported or manuel entered tasks
in the project plan, it is necessary to move these tasks and let them
stay, where they (now) are. I know, that intrinsically this is a
problem of time-sequence or history, but I hoped to go around a
complicated procedure to manage a history of every task to every time
and I feel, this way will lead to other heavy problems or failures.

For example...
state 0:

manual entry (before moving)
inserted entry 111
inserted entry 111
inserted entry 222
inserted entry 222

state1:

inserted entry 111
inserted entry 111
inserted entry 222
manual entry (after (first) moving, should stay here)
inserted entry 222

state3:
There will be some new inserted entrys at the end of state1, unsorted,
like
inserted entry 117
inserted entry 003

so the result should be:

inserted entry 003
inserted entry 111
inserted entry 111
inserted entry 117
inserted entry 222
manual entry unsorted, same relative, not same
absolute positon
inserted entry 222

Let us pray to learn in our next life a better profession and not to
have thinking about such things - but in the moment, we are in this
life.

yours Uli (Ulrich Roos)
 
U

uli

Hi Jack,

sorry, forgot to confirm that your nice banana-apple example
principally the thing is I meant, so it was superfluous to write my
boring state0-x examples.

Uli
 
R

Rod Gill

Hi,

Would this work?

In Project Insert the field Number1
Copy the ID to Number1

Copy the task to be sorted with their Number1 fields to Excel
Sort in Excel
In Excel, if the lowest ID number was 125 over-write the Number1 column with
125, 126 etc (use fill down to do this quickly)
Copy the Number1 values into Project and over-write the original number1
numbers
Sort Project by the Number1 field.

All other tasks should stay where they are, but by you re-ordering the
Number1 fields for your tasks, they get sorted.

--

Rod Gill
Project MVP

NEW!! Project VBA Book, for details visit: http://www.projectvbabook.com


Hello Jack,

thanks and let me time to think about your contribution... I answer in
this regard later.

But - as you asked for some background information - here meanwhile my
reasons for the "some-out-of-sorting-project" and a sample in some
states:

In an existing ms-project sheet with some manual entered tasks (id est
the non-to-sort tasks) a software named CleanQuest inserts a bundle of
tasks. This inserted (or imported) tasks are possesing in a text field
a code like 001 or 222 or 452 and so on. Therefore you can sort and
hold together this inserted tasks. The import of this inserted tasks
begins always at the end of the already existing tasks and they must be
sorted, because their order is unsorted.

To arrange freely some of the inserted/imported or manuel entered tasks
in the project plan, it is necessary to move these tasks and let them
stay, where they (now) are. I know, that intrinsically this is a
problem of time-sequence or history, but I hoped to go around a
complicated procedure to manage a history of every task to every time
and I feel, this way will lead to other heavy problems or failures.

For example...
state 0:

manual entry (before moving)
inserted entry 111
inserted entry 111
inserted entry 222
inserted entry 222

state1:

inserted entry 111
inserted entry 111
inserted entry 222
manual entry (after (first) moving, should stay here)
inserted entry 222

state3:
There will be some new inserted entrys at the end of state1, unsorted,
like
inserted entry 117
inserted entry 003

so the result should be:

inserted entry 003
inserted entry 111
inserted entry 111
inserted entry 117
inserted entry 222
manual entry unsorted, same relative, not same
absolute positon
inserted entry 222

Let us pray to learn in our next life a better profession and not to
have thinking about such things - but in the moment, we are in this
life.

yours Uli (Ulrich Roos)
 
U

uli

Hi Jack,

I suffer from some banana-apple-yours-and-mine-example-confusion... and
here in Germany it's sleeping time

There is a difference between the banana and my model. In your
banana-language:

you:
banana3 (no sort) holds its absolute position:
apple1
apple2
banana3 (No Sort)
apple3
apple4
apple5
apple6
banana1
banana2


me:
banana3 should hold its relative postion. In this case: banana3 follows
banana2, because banana2 was the above item before sorting:
apple1
 
U

uli

Hello together,

thanks for hints from Rod (wouldn't handle an additional application like
Excel) and Jack.

I solved it that way:

The manually inserted and not-to-sort tasks are residing in task-blocks with
a common attribute, for example this entry in a text field: "xxx0009".

So I wrote code to get this "xxx0009" from an above task, set it in the line
of the manual inserted task and therefore this task will remain in relative
position.

Only a workaround, but in my case possible and easier than working with
arrays or other possible solutions.

yours Uli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top