Task ID and Predecessor with VBA

Copper Contributor


In a mpp file I have the tasks ID and predecessors of many tasks. I need to transmit them into another mpp file using VBA. The tasks are not listed in the same order.

How can I do that ?

Thanks and regards

6 Replies
Whoa, wait a minute, what you're asking doesn't make a lot of sense. What exactly are you trying to do? And why do you think you want to do it?

If the tasks in the other file are in a different order, all the IDs and predecessor (IDs) will be completely different, hence your request doesn't make much sense.

I am not sure why you would want to do this however
1) If the tasks have something in common (name, Unique ID etc) which means that you know that Task 1 in the original file is is actually task 10 in the new file then you can use this information as a key in Excel and use a VLOOKUP; copy the data from the Original File into one set of columns and then copy the information from the new file into another set of columns and use VLOOKUP to transfer the data and then copy and paste back into MSP
2) Copying the tasks (i.e. the whole line) from one plan to another will take across all data including dependencies but I suspect this isn't what you're trying to do.
Maybe some more information about what you're trying to do will help people to come up with ideas?
Robert --

Why don't you just use copy and paste? Using VBA seems like overkill, unless you have some very special need for doing so. Maybe you need to explain what you are trying to do and then we could help you.
Thanks for trying to help me.
I'll try to explain more accurately.
The user created a schedule: 1600 tasks and a WBS, and then he activated a grouping.
Now he wants the structure of the grouping as a new WBS.
The Copy and Paste works fine for most of the fields, but it doesn't work for the Predecessors column. For example, in the original file the predecessor of Task 3 was Task 2, but in the new file Task ID 2 is its own summary.
Any idea?
Thanks again
You're expanded "explanation" is still a bit iffy. Your original post mentioned two separate(?) files but it sounds like you have a single file that you want to re-structure based on grouping.

You do understand that grouping does not create new summary lines, right? Grouping simply creates a custom "sort" with "summary lines" for display only. Here's an idea that may make this a whole lot easier.

Instead of grouping, use the sort feature to re-organize the file as desired. Select the option to "permanently renumber tasks". The task dependencies will automatically re-align based on the new task IDs. The WBS can be manually adjusted to the new outline.

If your file structure is more complex (i.e. the above scheme doesn't work for you), then you'll have to provide us with more details (e.g. some screen shots of a before and after sampling) in order for any of us to give a better answer. That answer may or may not involve the use of VBA.

The real issue may arise if your user has linked to or from Summary Lines - I would remove these before attempting to run the group and re-order as per Dale's comment. There will be some manual work to build the new WBS and structure however this will not be a massive task and will be a lot less than messing around with VBA I suspect :)