Forum Discussion
Comment remplacer une ressource par une autre en VBA
Bonjour,
J'ai un problème fort simple, mais que je n'arrive pas à résoudre en VBA.
J'ai une ressource, on va dire Toto
J'ai une autre ressource, on va dire Tutu
Je voudrais transférer les données Réels de Toto vers Tutu avec un script VBA.
Aujourd'hui, j'y parviens avec des boucles sur les affectations et les données réelles dans le temps (TimeScaleDate) de Toto, mais ça prend une éternité.
Est-ce qu'il existe une façon simple d'y parvenir?
Merci par avance,
Thanks for your help, I've tight schedule to respect, and have no time for translating and editing code to make it smaller.
I guess, I'll have to take another approach that is less tedious, althought it might require much more manual editing.
10 Replies
- John-projectSilver Contributor
pascalito,
It depends. If for example Toto is no longer available (e.g. left the company), then it could be as simple as replacing Toto on the Resource Sheet with Tutu (i.e. change the resource name).
However, if Toto is still active elsewhere in your plan you will need to "capture" Toto's assignment information on each task and switch that over to Tutu.If Toto is the only resource assigned to a task, then capturing his assignment units and actual work, if any should be all you need to make the transfer. Then delete Toto as the assigned resource, and add Tutu as the assigned resource using the captured assignment units and actual work.
If multiple resources are assigned to a task and Toto is one of them, you will need to capture Toto's assignment units, actual work, and assignment start and finish. Then delete Toto's assignment, add Tutu as a resource using the captured assignment data.
If Toto's assignment is non-linear (i.e. contoured) and you want to replicate that contour for Tutu, then you will have to make the transfer period by period using timescaled data. But if Toto's assignments are all linearly spread over the task duration, then the above simpler approaches should get you there.
Let me know.
John- pascalitoCopper Contributor
Bonjour John,
C'est hélas bien ce que je craignais, dans le cas d'utilisation qui m'intéresse, je cherche à conserver les données de notre ami Toto parce que sa définition change, e.g. nouveau rôle, et donc pour préserver ces caractéristiques, je crée une copie de Toto dans une nouvelle fiche ressource, que j'appelle Tutu
Je transfère tous les réels de Toto sous Tutu. Pour les projets qui sont terminés, j'ai trouvé beaucoup plus rapide d'ouvrir les plans et de procéder à un remplacement de ressource Toto par Tutu. Ce qui se fait en un éclair.Par contre, pour les projets en cours, j'utilise un script VBA, je balaye toutes les tâches de Toto, je crée une nouvelle affectation pour Tutu, puis après je boucle dans le temps depuis le début de l'affectation jusqu'à la date effective, je mets les réels pour ce jour dans la nouvelle affectation et j'efface les réels de l'ancienne affectation.
Ça marche très bien, au détail près que ça prend une éternité, à chaque transfert le statut passe de Prêt à Occupé. Et j'aurais aimé accélérer le transfert.
- John-projectSilver Contributorpascalito,
For further posts please use English as this an an English based forum. I can translate using Google's language translator but that doesn't update the thread for the benefit of other users who may follow.
It sounds like you've figured out a process that works for the various scenarios (e.g. completed projects and on-going projects) but here's an idea you might want to consider. Save a copy of the plan with Toto as the resource, then save the plan under a new name and change the Resource Sheet such that Toto is now Tutu. True, the new plan will show Tutu as the original assignment but the difference in actual work (and any other resource attributes) is a "simple" subtraction of the plan saved with Toto and the new plan with Tutu. When I say "simple", this subtraction can be accomplished in various ways, a macro that uses extra fields in Project or better yet, a macro that exports data to Excel and customizes a report of the differences. I've done macros like that for years.
With regard to your macro taking a long time to run, it may be because the amount of data is very large or it could be the method(s) you are using in your VBA code. Some of my macros take a couple of minutes to fully execute when operating on large amounts of data but most run in a few seconds. Would you be willing to share your macro code with me and also your Project plan. Perhaps I can peruse your process and suggest ways to speed up processing. Keep in mind I do not speak French. If you're interested, let me know.
John